School shapes our ends - almost literally so in the case of the more sexually promiscuous male public schools. How and where you were educated has a big influence on your whole life. I might not have ended up a critic (a prospect some will entertain with relish) had it not been for a trio of English teachers who fostered a love of theatre and analysis. I can also date my political awakening from the moment a peculiarly detested fellow pupil burst into my public school classroom the day after the 1951 general election shouting: "We're in" - meaning, of course, the Tories. His arrogant assumption that we were all of the same persuasion meant I became a lifelong Labourite on the spot.
The idea of school as the formative period of your life is one of many notions threading through Alan Bennett's The History Boys. This is one of those plays that seems immediately to have captured the public imagination. But then the middle-class English have a special fondness for plays that take them back to their educated adolescence, whether it be jolly farces like The Happiest Days of Your Life and Daisy Pulls It Off or serious dramas like Terence Rattigan's The Browning Version and Julian Mitchell's Another Country. What has taken time to sink in however (especially after its hectic, fire-prefaced first night) is just how radical Bennett's play is. It's not just about history. It also makes it.
For a start, it's the only school-play in English drama that is about the process of teaching. Not just about the sexuality or politics of school life but about the daily process of opening up young minds. We actually get to see the heroic Hector and the insidious Irwin - the play's intellectual antagonists who happen to be in the same boat sexually - at work in the classroom.
One scene, where Hector takes a shyly precocious pupil through Hardy's poem Drummer Hodge , is overwhelming in its emotional impact. It is partly because the teacher gently elicits from the boy, and imparts to him, an understanding of the poem: its relation to Rupert Brooke, its Larkinesque use of compound adjectives, its commemorative naming of a common soldier which is a practice that began only with the Zulu and Boer wars. But the scene does many other things. It demonstrates the unfashionable virtue of committing a poem to memory. It shows Hector finding an echo of his own sad life in the drummer thrown into some "uncoffined" grave and in Hardy's own unappreciated existence. And it states a profound general truth: that "the best moments in reading are when you come across something - a thought, a feeling, a way of looking at things - which you had thought special and particular to you".
Bennett shows what teaching at its best is: a process of drawing out rather than putting in. But he does infinitely more than that. He understands that a school is a network of private relationships and a public institution; a place in which a precariously maintained order is constantly on the verge of disintegrating into chaos; and, especially, a battleground for opposing views of life and education. But what he sees more sharply than anyone is that a school is a paradigm of national life.
His 1980s grammar school is an image of Thatcherite Britain. It has a dictatorial boss, a sceptical feminist element aware that history is a catalogue of "masculine ineptitude" and a central conflict between bustling pragmatism and beleaguered humanism. In Forty Years On, Bennett called his school Albion House. Here the symbolism is unnecessary. The school simply is 1980s Britain.
Bennett's most radical step is to use the intricacies of school life as a way of advancing his own view of history: one that emphasises the randomness of events rather than grand designs and impersonal forces. The boy-fondling Hector is exposed simply because the headmaster's wife happens to see him out of a window while doing a stint at Age Concern on a Wednesday afternoon. As Frances de la Tour's teacher says: "This smallest of incidents is the junction of a dizzying range of alternatives, any one of which could have had a different outcome."
But Bennett's prime concern is with how history actually happens. In a brilliant earlier scene, a pupil makes a coded move on the closeted Irwin while illustrating the chanciness of events. Anxious to impress, the boy points out that when Chamberlain resigned as prime minister in 1940, Lord Halifax rather than Churchill was his preferred replacement. But on the key afternoon when the decision was taken, Halifax chose to go to the dentist. "If Halifax had had better teeth," the boy points out, "we might have lost the war."
That's both an example of the jaunty journalistic cleverness that gets good exam results and a demonstration of Bennett's own belief in the accidental nature of history. For some, like Macaulay and Trevelyan, history is a steadily unfolding narrative with a pleasing aesthetic shape. For others, such as Eric Hobsbawm or EH Carr, history exemplifies Marxist theory. But Bennett's view is closer to that outlined by Geoffrey Barraclough in An Introduction to Contemporary History . "Bertrand Russell," Barraclough writes, "once said that 'the universe is all spots and jumps' and the impression I have of history is much the same. At every great turning point of the past we are confronted by the fortuitous and the unforeseen, the new, the dynamic and the revolutionary; at such times, as Herbert Butterfield once pointed out, the ordinary arguments of causality are 'by no means sufficent in themselves to explain the next stage of the story, the next turn of events.'"
Countless dramatists before Bennett have gone back to school for drama. But Bennett's play outshines its predecessors because it is about the tragic and fulfilling aspects of teaching, about the changing face of England and ultimately about the nature of history itself. At first it seems a bit wild and ramshackle: a collection of very funny and moving scenes without any visible grand design. But it strikes me that Bennett is putting into practice his own belief that life, like history, is a series of chance occurrences on which we later impose a pattern.
The History Boys defies categorisation - and for this reason, it is the most experimental play in London. It owes little to past models. It subversively mixes up drama, comedy, poetry, popular song and ancient hymns, anecdote and aphorism, WH Auden and Gracie Fields in an eclectically English way. Obviously the play has a controlling intelligence. But just as Hector's life is ruined by a casual glance out of a window, so Bennett's own play was nearly sabotaged by an opening-night fire. In the end, as Bennett says, we are all at the mercy of "the utter randomness of things".
· The History Boys is in rep at the National Theatre, London SE1. Box office: 020-7452 3000.