Partly overcrowding; partly appalling sanitation. In 1858, the problem was brought to the attention of Parliament in a very forcible way: overflowing of sewers (even more than usually!) into the Thames caused the 'Great Stink' which attacked everyone's noses, including those sitting in Parliament. They considered relocating Parliamentary sessions elsewhere. At any rate, it brought home some of the reasons why there were so many epidemics of cholera and other diseases in London.
Here's a link to some 19th century cartoons and writings about 'filthy London'.
http://www.victorianlondon.org/health/thamescondition.htmIn the later 19th century, more attention was given by London officials and by Parliament to improving drainage and the awful sanitary conditions. River pollution continued into the 20th century, and air pollution, always bad, increased. Smogs were common. In 1953, a particularly awful smog led to about 2000 excess deaths in London within about a week - and this shocked the government into passing the Clean Air Act, which restricted both industrial and domestic use of pollutants. By the time I was born in the 1960s, it was forbidden to use coal fires for domestic heating in most parts of London. As a child, I spent a year in Edmonton in Canada and was startled by the smogs and obvious air pollution *there* (including very colourful smoke coming from the local power station) - rather to the amusement of people who didn't expect a child from London to be commenting on the smogs of a Canadian prairie town!
A lot has been done, through regulation, to clean up the Thames. I still wouldn't recommend going for a swim in it; but it's not what it was in the Good Old Days.