In his working notes for the 15th serial episode of Bleak House, Charles Dickens pondered what to do with the creation to whom every reader's heart had gone out, the pathetic street waif, Jo ("He wos wery good to me, he wos"). "Jo?" the author asked himself. "Yes. Kill him." Thus Jo went the way of Little Nell and Paul Dombey. The poor unsuspecting urchin was slaughtered by his creator as heartlessly as the turkey Scrooge ordered from another little urchin for Christmas. In May 1853, shocked Victorian readers wept inconsolably for their loss and, more importantly, signed on to Bleak House for the duration.

Dickens was as much a master of "make 'em laugh, make 'em cry, make 'em wait, make 'em come back" as the writing teams that come up with the never-ending storylines swirling around Albert Square and "the Street". Dickens, for example, knew just as well as those who devised the demise of Dirty Den that one of the ways to bump up reading/viewing figures was to wield the executioner's axe. As a fellow serialist, Dickens would have admired the "curtain lines" (or cliffhangers), the crosscutting, the finely judged alternations of comedy, sentiment and pathos that we get today in EastEnders. As an inveterately cockney novelist - "Boz" - he would also have felt comfortable with the location. (How does Bleak House begin? With one word: "London.")

Above all, Dickens would heartily have approved of the "soap" association in soap opera. Why are they called soaps? Because, in the 1950s, when they began to dominate afternoon television in the US, the serials were sponsored by the big detergent firms, aimed at middle-class housewives with nothing to do in the afternoon but watch the box and load the washer. Hence, "soap opera".

At the period he was writing Bleak House, sanitary reform - soap for the nation - was an obsession with Dickens - his idée fixe, his hobbyhorse, his mania, one of the few topics on which he could be boring. "In all my writings," he wrote in his preface to the 1844 novel, Martin Chuzzlewit, "I hope I have taken every available opportunity of showing the want of sanitary improvements in the neglected dwellings of the poor." Soap fiction, in a word, was what interested Dickens most.

One finds the obsession with cleanliness everywhere in Bleak House. Dickens's filthmeter is always turned on. It goes into whirring overdrive in such scenes as that of the first visit to the brickmakers' hovel in St Alban's. "Is my daughter awashin?" asks the drunken brute of a brickmaker, in response to Mrs Pardiggle's condescending inquiries as to the state of his soul and whether he has read the uplifting tracts she has kindly left him: "Yes, she is awashin. Look at the water. Smell it! That's wot we drinks. How do you like it, and what do you think of gin, instead? An't my place dirty? Yes, it is dirty - it's nat'rally dirty, and it's nat'rally unwholesome; and we've had five dirty and onwholesom children, as is all dead infants, and so much the better for them, and for us besides. Have I read the little book wot you left? No, I an't read the little book wot you left."

In a speech to the Metropolitan Sanitary Association 10 months before the launch of Bleak House, Dickens declared his great mission as a reforming novelist: "I can honestly declare tonight, that all the use I have ... made of my eyes - or nose [laughter] that all the information I have since been able to acquire through any of my senses, has strengthened me in the conviction that searching sanitary reform must precede all other social remedies [cheers] and that even Education and Religion can do nothing where they are most needed, until the way is paved for their ministrations by Cleanliness and Decency [hear, hear]. What avails it to send a Missionary to me, a miserable man or woman living in a foetid Court, where every sense upon me for delight becomes a torment, and every minute of my life is new mire added to the heap under which I lie degraded? To what natural feeling within is he to address himself? ... But give me my first glimpse of Heaven through a little of its light and air - give me water - help me to be clean."

"Help me to be clean": that is what the unfortunates who crowd the pages of Bleak House are saying. Dickens had plenty of his own experience of deprivation to draw upon; he was one who, as the Victorians liked to say, "grew towards the light", proving that anyone could succeed. He was born on February 7 1812, at Portsea, the son of John Dickens, an £80-a-year clerk at the Navy pay office, and Elizabeth, daughter of a senior clerk in the Navy pay office who, in 1810, was exposed as an embezzler - probably influencing a number of Dickens's characters.

There were 10 Dickens children, five of whom survived childhood. Charles (nicknamed "Boz") was the eldest son. His early childhood was traumatically unsettled (a version of it can be found in David Copperfield). The family moved to London in 1816, to Chatham in 1817, and back to London again in 1822 to settle in Camden Town. John Dickens's salary (now £350 a year) should have been adequate but, like Mr Micawber, he lived beyond his means.

By 1824, the Dickens family had passed beyond penury into bankruptcy. Everything in the house was pawned. John Dickens was imprisoned for debt at the Marshalsea Prison (an event that would resurface as the central plot element in Little Dorrit). At the age of 12, Charles was put to work at a shoe-blacking factory on the south bank of the Thames (where the Hungerford footbridge now stands), at a wage of six shillings (30p) a week. Although this menial labour lasted only a few months, the "secret agony of my soul" was remembered for the rest of Dickens's life. He could easily, with another push downward, have become another Jo. The abyss was never far away.

A small legacy enabled the family to discharge their debts a few months later and Charles was sent to a decent London school. In 1827, however, the Dickens's finances were again precarious and Charles was articled as a solicitor's clerk in Gray's Inn, at something less than £1 a week. He hated the law with a ferocity that can be felt, a quarter of a century later, in Bleak House.

Already a skilled penman, Dickens was attracted by journalism. He learned shorthand and became a parliamentary reporter for the newspapers. By the early 1830s, he was earning around £5 a week and writing more creative reportage. This led to his first success as a writer, Sketches by Boz, a series of snapshots of London that show Dickens, still barely 25 years of age, as an accomplished writer. Spectacular success came with the Pickwick Papers, which began selling in monthly parts in April 1836.

Serialised between March 1852 and September 1853, Bleak House is a pivotal novel. Dickens wrote, as the Victorians put it, "fiction with a purpose". Thus, in Bleak House, filth emerges as the true villain, surpassing the evils of the sadistic lawyer Tulkinghorn, or the homicidal Hortense, the insectoid stalker Guppy, or the vampiric Vholes. Specifically, airborne filth, rising mephitically from the open sewers, from the "nightsoil" (human excrement dumped in the gutters), and the animal droppings that caked the open streets. "Mudfog" Dickens liked to call that poisonous atmosphere - for which read (and, with the mind's nose, smell) "shitair".

Hanging on the railings outside the Jellybys' house, we are told, there are milk and beer cans. Why the latter? The household drinks milk and beer because there is no supply of mains water, and that water available from the street pumps (which served London's households) was highly dubious. On the north side of London, these public sources of water would be shallow wells. On the south side of the Thames, tidal ditches.

There had been a devastating outbreak of cholera in London a few months before the publication of Bleak House. There were two theories of how it was spread. The most popular was the "miasmic" theory, where poisonous air acted as the vector. From the introductory fog onwards in Bleak House, it is evident that Dickens inclined to the miasmic view. The alternative was that the disease was carried by water contaminated by sewage, particularly by nearby cesspits. Dr John Snow was a main proponent: he proved the theory in 1854 (while Bleak House was still the book of the day) by vandalising the handle of the pump in Broadwick Street, which served the large population in Soho. The cholera incidence in the area dropped instantly as the local population turned to beer to quench their thirst.

At Bleak House, in rural St Albans, Mr Jarndyce's water would have been pure, the household served by a pump in the yard behind the kitchen, whose effluent would be crystal clear. In the Jarndyce town house, more care would be taken.

In London, the main sanitation problem then (as now) was how to dispose of human waste products. Four years after Bleak House, Joseph Bazalgette began his great project to lay a sewage system beneath the city. His pioneering infrastructure purified London, and Londoners still rely on it.

Victorians, rightly, saw Dickens not merely as a great entertainer, but as a force for progress. Bleak House is what Carlyle would have called a "Condition of England" novel. Despite his reforming "mission", however, Dickens was careful - as any soap opera serialist must be - to stress human interest and, specifically, love interest. As he wrote in his (postscript) preface: "In Bleak House I have purposely dwelt upon the romantic side of familiar things." Who will Esther, the humble, illegitimate housekeeper marry? This is the romantic question that gathers over the second half of the novel, becoming almost as pressing a question as "Who is Jo's murderer?" or "When the hell are they going to do something about that Court of Chancery?"

Accustomed as they were to love stories, Victorian readers felt a piquant novelty surrounding that word "murder". There was, of course, plentiful homicide in the traditional English novel (Gothic fiction is awash with gore). But with Bleak House, Dickens did something unusual; he stressed less the bloody crime (which we do not, in fact, witness), rather the detection of the crime. Bleak House can plausibly claim to be the first "whodunnit" in English literature. The perpetrator, of course, is ingeniously discovered by the sibylline Inspector Bucket - progenitor of Morse, Dalgleish, Rebus and all those other sleuths of popular fiction.

Bleak House was Dickens's ninth novel. He was, by this stage in his career, a master of his narrative instrument. A major novel would yield him, in Victorian money, about £10,000. No other author, with the possible exception of Sir Walter Scott, had earned as much. Dickens wrote all his novels in serial form - "lisping in numbers" - which he preferred for several reasons, primarily because it brought him closer to his audience. Amazingly, he himself often did not know what was coming next, as his working notes testify - Dickens loved to let his novels work themselves out; "writing to the moment", as he called it. Every month, he got a feel for the success of the story, not least by the monthly sales figures that his publisher, Bradbury and Evans, reported back to him. Readers would write to him, friends would discuss how the story was going - it was the most participatory kind of fiction.

Dickens was also heavily involved during the 1850s in amateur theatricals, with the aim of raising money for charitable causes. These performances brought him into contact with the young actress Ellen Ternan who later, probably, became his mistress. The Dickens marriage had been unhappy for some years and the couple formally separated in 1858.

That year, Dickens had begun a series of immensely popular public readings from his work in Britain and America. Only two more full-length novels were embarked upon: Our Mutual Friend (1864-65) and The Mystery of Edwin Drood (1870), which was cut short by his death in June of that year. In 1864, his health had begun to deteriorate with symptoms of gout and the early warnings of an impending stroke. In June 1865, he and Ternan were involved in a train crash at Staplehurst which shattered his nerves for months afterwards. Still, in defiance of medical advice, Dickens continued with a gruelling schedule of readings, including a triumphant (and richly remunerated) tour in America in 1867 and '68.

He died in the dining room of his house at Gadshill of a cerebral aneurysm on June 9 1870. The author was buried five days later at Westminster Abbey, widely mourned as the greatest British writer since Shakespeare.

· This is an edited extract from Inside Bleak House by John Sutherland, published by Gerald Duckworth. To buy a copy for £6.99 with free UK p&p visit Guardian.co.uk/bookshop or call 0870 836 0875. Bleak House starts on BBC1 on Thursday, October 27.