Henry James once said that "really, universally, human relations stop nowhere," and that the exquisite problem of the writer is to draw the circle "within which they shall happily appear to do so". James would never have nominated War and Peace – he famously thought it a "loose baggy monster" – but Tolstoy's novel is surely the greatest attempt in the history of the genre to represent and embody the branching infinity of human relations of which James spoke. And there is no better example of that challenge than the way in which Tolstoy's project kept growing. He wrote War and Peace between 1863 and 1868, and intended, at first, to write a domestic chronicle in the manner of Trollope (whom Tolstoy, with a few qualifications, admired). The novel would be set in 1856, and concern an aristocratic revolutionary and his return from exile in Siberia. It would be called, improbably, All's Well That Ends Well. But in order to explain the atmosphere of Russia just after the Crimean war, Tolstoy felt he had to go back to 1825, when the Decembrists, a group of largely upper-class rebels, were arrested, and either executed or exiled. And 1825, he later said, could not be described without going back to the momentous year of 1812, when Napoleon invaded Russia and occupied Moscow for a month. Yet 1812 obviously needed 1805 as a proper prelude – which is where War and Peace begins.

Inexorably, what began as Russianised Trollope widened and deepened, until it became nothing less than the attempt to write the history of Russia during the Napoleonic campaign – in fact, it became the quarry that Tolstoy had identified as a young man, in his journal: "To write the genuine history of present-day Europe: there is an aim for the whole of one's life." And as this originally "English" novel became more complex and ambitious, so it became singular and unconventional. Tolstoy claimed that it was "not a novel", at least in the familiar, European sense. We Russians, he said, produce strange misfits, awkward black sheep, like Gogol's unfinished picaresque, Dead Souls, and Dostoevsky's semi-fictionalised account of his time in a Siberian prison camp, The House of the Dead. Gustave Flaubert seemed to agree. Admiring and horrified, he complained that Tolstoy "repeats himself, and he philosophises": sins good formalist novelists should not commit.

Impatient with both traditional history-writing and traditional novel-writing, Tolstoy breaks into his fictional narrative with essays and lectures about free will, determinism, history and power. A superb fictional account of the battle of Borodino is followed by a slightly grumpy military history of the battle and a map of the battlefield. Throughout the novel there is authorial argument, admonishment, preaching – a clear desire to correct the "official" record and write the proper history of the Napoleonic invasion; truth, you feel, is being battled for, with whatever literary weapons come to hand.

Many readers tend to agree with Flaubert, and either skip or speed read the essayistic passages about historiography. There is a tradition, particularly in English letters, of separating "Tolstoy the artist" from "Tolstoy the preacher"; the long chapters about European history, it is sometimes thought, are prolix leavings, while the rich stories of Natasha and Pierre, Prince Andrei and Nikolai Rostov, are precious loans. Keep the great realist novelist, jettison the great irritable arguer. But Tolstoy is at once a preacherly artist and an artistic preacher, and it is as hard to divide him into two distinct selves as it is to divide DH Lawrence into sermonising high priest and storytelling layman.

Moreover, there is something emphatic and pedagogical about Tolstoy's storytelling; he is teaching even when telling a tale. He is simple and direct and emphatic – sometimes he seems more practical and childlike (perhaps "innocent" is the right word) than most great novelists. He is not afraid to begin an episode with a throat-clearing "Here is how it came about" – the kind of phrase we encounter in fairytales. Tolstoy is a great creator of palpable individuals – the "little princess" with her short upper lip and faint moustache; Pierre Bezukhov, bumbling short-sightedly on to the battlefield at Borodino; the old Prince Bolkonsky, with his rages and his "small dry hands"; a shirtless Napoleon, grunting to his valet, who is brushing his fat back and hairy chest, "Do it hard, keep going" – but the Tolstoyan atmosphere often seems Homeric because these highly particular characters essentially share simple, large, universal emotions – joy, shame, love, anger, fear – that might easily be transferred from one character to another. Nikolai Rostov, for instance, has a young man's exuberance and solipsism; he goes to war "because he could not resist the wish to go galloping across a level field". But all his young male friends and fellow soldiers might feel the same way. Essentially, Nikolai is like all healthy young men. Prince Andrei and Pierre Bezukhov both have religious experiences, but their metaphysical curiosity is almost interchangeable (and essentially indistinguishable from Levin's, in Anna Karenina). There are female "types" in Tolstoy, too: young Natasha in War and Peace has some of the passionate curiosity and waywardness of young Kitty in Anna Karenina, while older, seasoned Natasha (the woman we encounter at the end of the novel, contentedly married to Pierre Bezukhov) has something in common with the wiser, seasoned Kitty who eventually marries Levin. And so on.

Leo Tolstoy with his wife, Sofia, in their garden in around 1906. Photograph: Hulton-Deutsch Collection/CORBIS

In essence, Tolstoy's novel is a story of two families, the Rostovs and the Bolkonskys, and an eccentric outlier, Pierre Bezukhov, who moves between them. The drawing rooms of Petersburg may feel far from the blood and dirt of Napoleon's campaign, especially when the novel opens, but "war" and "peace" inexorably converge: Prince Andrei Bolkonsky goes to fight Napoleon, as do Petya and Nikolai Rostov. Natasha, engaged to Prince Andrei, will experience the agony of his slow death after Borodino, in 1812. Petya is fatally shot by the French. Pierre Bezukhov, the clumsy, questing aristocrat, journeys from Moscow to the Borodino battlefield, an incongruous sight in the theatre of war, dressed in a tall white hat and green trousers. Pierre is imprisoned by the French, and avoids execution by sheer luck. He eventually marries Natasha. A touching epilogue shows two couples, four survivors of history, happily married seven years after Napoleon's defeat: Natasha and Pierre, and Nikolai and Marya (the old Prince Bolkonsky's daughter). Some readers have felt it to be an uninspiring domestic coda, at best a cool diminuendo after hundreds of pages of glittering volume. But something is simmering, too. Pierre is convinced that some kind of uprising will be needed in order to sweep away corruption and mismanagement at the highest levels in Petersburg. Nikolenka, the teenaged son of the late Prince Andrei Bolkonsky and a great admirer of Pierre, has a dream in which he sees himself as a soldier in the ranks of the revolutionaries. The novel here clearly foreshadows the Decembrists' rebellion of 1825, as if Tolstoy, returning to his first plans for the book, were preparing the ground for a sequel, one that might have continued the historical record all the way to 1856, the original starting point of his narrative.

And, in fact, War and Peace does not quite conclude with this glimpse of married happiness, but with another slightly irritable instalment of pedagogy – a 35-page essay in which Tolstoy returns again to the animating theme of his great work. It could be said that just as the "peace" side of the novel is about two great families and an outlier, so the "war" side is about two great families and an outlier – the people of France and Russia, and the singular Napoleon, the military genius who drives them together. Tolstoy disliked not only Napoleon's vanity and egotism (his descriptions of the Frenchman are always amusingly biased), but also the egotism of most 19th-century historical writing, which, as he saw it, tended to venerate precisely the historic singularity of Napoleon at the expense of the ordinary, inglorious, invisible Russian or French soldier.

Hegel had described Napoleon as the world-spirit on horseback. Tolstoy found that the historians seemed to agree; they asserted, as he puts it in his novel, that thousands of people went from west to east and killed each other just because a single man told them to. Even those historians interested in multiple causes never seemed to respect enough of them, thought Tolstoy. Great occurrences like the Napoleonic invasion happen not because one man dictates the movement of history, but because hundreds of thousands of motives and accidents and reactions occur at once; Tolstoy called this the "swarmlike life, where man inevitably fulfils the laws prescribed for him". He is really a kind of historical fatalist who spends the course of his novel searching for the laws of that fatalism. Napoleon and great men like him think of themselves as supremely free, but in fact they are the servants of history, as caught up in that "swarmlike" existence as the meanest hussar.

On the eve of the battle of Borodino, Napoleon announces that "the chessmen are set up," but a few pages before, Pierre had compared war to chess, only to earn Andrei's scorn: "Yes … only with this small difference, that in chess you can think over each move as long as you like, you're outside the conditions of time." Since one is never outside the conditions of time, the right conclusion to draw, thinks Tolstoy, is a kind of epistemological modesty: we always know far less about the laws of life than we thought we did. "The more we try to explain sensibly these phenomena of history, the more senseless and incomprehensible they become for us." One result of this wise modesty, when coupled to a large, restless intelligence like Tolstoy's, is a very large novel, the form of the book loyally obeying the limitlessness of the inquiry: many stories, many lives, many repeated attempts at explanation.

Another result is that Tolstoy's characters often have to learn the same lesson that Tolstoy himself learned in the course of his reading and writing. Repeatedly, the men and women in this book are forced to break out of their own often infectious solipsism, in order to acknowledge that other people's lives, or other great truths, are as important as the truth of their own existence. Nikolai Rostov imagines that war will be an exciting business of cutting people down. But it isn't much like that, and when he has the chance to kill a Frenchman, he can't do it, because the enemy has "a most simple, homelike face". Returning home from battle, Andrei discovers two girls stealing plums from the trees on his family estate and is obscurely comforted, feeling "the existence of other human interests, totally foreign to him and as legitimate as those that concerned him". Pierre Bezukhov is forced out of his massive self-involvement by his shattering experiences in Moscow, during which he witnesses the execution of five captives, narrowly escaping the same fate himself. He begins to understand his life in its connectedness to everyone else's, and to a larger metaphysical body: "the ever-changing, ever-great, unfathomable, and infinite life around him".

Reality, in Tolstoy's world, is a matter of such constant adjustments and necessary estrangements. There are large reckonings and there are many small ones, these forming part of the sweet-natured and often comic flow of Tolstoy's narrative. Such a moment occurs, for instance, near the end of the book, when Marya enters the nursery: "The children were riding to Moscow on chairs and invited her to come with them." Tolstoy gives no further explanation of what the children are doing; he wants us to work it out for ourselves, exactly as if we had just entered the room, found the children at play, and spent a moment catching up with their imagined reality. The parent who might do this is forced, however briefly, to acknowledge the sharp otherness of a child's existence, made to realise what Andrei understands when he sees the girls running "merrily and quickly" to fill their skirts with plums: "the existence of other human interests, totally foreign to him and as legitimate as those that concerned him". And the reader is similarly jolted.

• War and Peace, translated by Richard Pevear and Larissa Volokhonsky, is published as a two-volume illustrated edition by the Folio Society.