It's wonderful stuff, swearing. It stiffens the sinews and summons up the blood, and not just metaphorically. Obscenities actually do act on us physiologically. Swearing increases electrical conductance across the skin, pushes the heart rate higher and measurably increases resistance to pain.

Obscenities are also linguistically interesting in themselves: the more currency they have, the more their emotional colouring and the associations they trigger overwhelms what they actually mean. "Fucking", these days, only rarely means "having sex". And they become marvellously plastic, grammatically.

Swearing doesn't just mean what we now understand by "dirty words". It is entwined, in social and linguistic history, with the other sort of swearing: vows and oaths. Consider for a moment the origins of almost any word we have for bad language – "profanity", "curses", "oaths" and "swearing" itself .

Melissa Mohr's title, then, is more than just an attention-grabber: the history of swearing is one of a movement back and forth between the holy and the shit. At different times in the history of the west, the primary taboo has been to do either with God, or with the functions of the human body. (The latter, though, does subdivide in a meaningful way between the sexual and the excremental. Really, this book should have been called "Holy Fucking Shit".)

Though Mohr is mainly interested in English, she is generous in roping in examples from outside it. A helpful and interesting chapter on ancient Roman filth does much to sketch the background, too. How do we know what was obscene in a dead language? By literary genre, essentially: if it was written on the toilet wall but didn't appear in satire, it was likely to be properly rude. English has a "Big Six": "cunt", "fuck", "cock", "arse", "shit" and "piss" (though Mohr plausibly suggests that "nigger" should now be in there). The Romans had a "Big 10": cunnus (cunt), futuo (fuck), mentula (cock), verpa (erect or circumcised cock), landica (clitoris), culus (arse), pedico (bugger), caco (shit), fello (fellate) and irrumo (er, mouth-rape).

So the Romans, like us, had a primary relationship between the body and the idea of obscenity – though their sexual schema was a little different, with shame attaching, above all, to sexual passivity. Sexual obscenity also, to complicate things, had a sacramental function – as witness the fruity ways of the god Priapus. Some of that shit was holy.

In medieval times, though, the emphasis was all on the holy. Common words for places and things contained vulgarities regarded as quite innocuous. London and Oxford both boasted a "Gropecuntelane", which is where the prostitutes hung out, and if you visited a country pond "there would've been a shiterow in there fishing, a windfucker flying above, arse-smart and cuntehoare hugging the edges of the pond, and pissabed amongst the grass". At the same time it's hard to recapture quite how shocking medieval people would find a vain oath.

Christianity was founded on oaths and covenants – as was the whole dispensation of feudal society. To swear an oath was to compel God to pay attention to your promise – and to do so in vain was to dishonour God and risk eternal damnation. Indeed, it was believed that if you swore on God's body – "'sblood!"; "God's bones!"; "by Christ's nails!" – you physically spilled his blood, broke his bones and tore out his nails in heaven.

Mohr credits the decline in the importance of oath-swearing to the rise of the merchant classes. Feudal society's scheme of estates was bound by chains of oaths between lords and vassals, right up to the king. Capitalism moved us from oaths to contracts: the oath before God became less important than keeping your word to business partners – and you didn't need eschatological terror to enforce that. Plus, there's the dry, old complaint that swearing constantly "devalues the currency". Between 1640 and 1660, around the civil war, men might have to swear as many as 10 conflicting oaths of loyalty if they wanted to keep their heads attached to their necks.

At the same time, something else was going on: the idea of privacy. In an age when everybody pissed and shat in public, and sex would as like as not take place in a room or even a bed shared with others, taboos around bodily functions weren't all that strong. Chaucer's "swiving", "toords", "queyntes" and "erses" were vulgar and direct, but they weren't obscene. One word was regarded in the late-18th and 19th centuries as so shocking that it was variously rendered "inexpressibles", "indescribables", "etceteras", "unmentionables", "ineffables", "indispensables", "innominables" "inexplicables" and "continuations". That word? "Trousers."

How things change. By the first world war, soldiers swore so much that the word "fucking" came to function as no more than "a warning that a noun is coming". Now even the extremest obscenities have lost their power to shock. In Irvine Welsh's novels, for instance, "cunt" is more or less a synonym for "bloke". It is telling that, where for the Romans the genitals were veretrum or verecundum ("parts of awe" or "parts of shame"), "in today's American slang, the genitalia are devalued as 'junk'".

The only actually taboo language is that of racial insult. Words like "wop", "kike" and "yid" (though not, interestingly, "nigger") were intended to give offence from the off – but only to those on the receiving end. As Mohr writes, the idea that everybody should find them offensive is a relative innovation. Not, it should be said, a bad one.

Mohr's scholarship seems to be sound and her approach positively twinkles with pleasure and amusement. She gives her chapters headings such as "Shit, That Bloody Bugger Turned Out To Be A Fucking Nackle-Ass Cocksucker!", and she's not above finding it funny that a paper on urinary incontinence was co-authored by Splatt and Weedon.

I'd like Mohr's account to have tipped a wink to Viz comic's monumental and still-growing Profanisaurus. Her argument might have been strengthened, too, by reminding us that Eric Cartman, in South Park: Bigger, Longer and Uncut, saves the world from Satan and Saddam Hussein with the words: "Fuck, shit, cock, ass, titties, boner, bitch, muff, pussy, cunt, butthole, Barbra Streisand!"

But here I pick nits. This is a cracking fucking book, and innominables to anyone who says otherwise.

• Sam Leith's You Talkin' to Me? is published by Profile.