In George Orwell's Animal Farm, the pigs declared themselves more equal than others, and the writer Mark Essig believes science justifies that arrogance.

Pigs can learn to perform complicated tasks such as opening a cage or even playing video games, and they can do it faster than any other animal. And yet the title of Essig's book about pigs - Lesser Beasts - reveals the reality for the animal. Far from the pig being more equal than others, man has wilfully ignored its brilliance and kept it low down in the hierarchy of species. Before they are eaten, they are hated.

Essig explores all the reasons for this hatred in his book, which is part a zoological history and part a call for change, and it starts with the basics, such as what a pig eats. The answer, as anyone who has been close to a pig will know, is pretty much anything, including rubbish, carrion, faeces and anything else that might be lying around. In 2012, an American farmer went to feed his sows and never returned; when the authorities later searched the sty, all they found were his dentures and a few scattered body parts.

There is also an obvious religious element to the dislike of pigs: the people of the Near East all practised different religions, but they agreed that the key sacrificial animals were goats, sheep and cows, and that pigs were unclean. The Israelites then made the rejection of pork a central tenet of their religious identity. Pigs came to signify sin, heresy and dirt and stood for gluttony and lust, two of the deadly sins. It did nothing for the pig's status in society and the attitudes were passed down and still linger, even now in our secular days - and even among those who eat bacon. What better punishment could there be for those who despise an animal than to eat it?

Essig digs down into the history of all this hatred and snuffles around for the facts, but the book maintains its grip because we know the final destination; we know how the pig is treated now. Essig's evolutionary history shows that for thousands of years pigs wandered around human settlements, transforming waste into food, but the 19th century saw the invention of the modern pork-packing line. Neutrally, scientifically, Essig describes what such a line was like: the legs bound by chains, the knife to the throat, and the jobs of the men who ran it - the shaver, the gut man, the organ man.

He also makes us face the death of the pig, quoting from Jude The Obscure: "The dying animal's cry assumed its final tone, the shriek of agony; his glazing eyes riveting themselves on Arabella with the eloquently keen reproach of a creature recognising at last the treachery of those who had seemed his only friends." Essig says Jude's horror in Thomas Hardy's novel was a modern reaction, but one that would soon grow increasingly common. Home killing became rare and slaughter happened far away, in slaughterhouses. But the distance, the fact that the pig's journey to death was hidden rather than open, came to carry a cost.

The cost was industrial farming and Essig takes us through it in all its horrifying detail. Fifty years ago, pigs lived mostly as they had always done, roaming on pasture, but in the 1970s they were moved into barns and kept in tiny pens; suddenly, the wood or the pasture or the sty became, at most, an 8ft square cell. Euphemisms were found to describe the process as well, such as "gestation crate" which means the 7ft by 2ft space where a sow will spend her entire life. The EU banned sow stalls in 2013, but many countries openly break the ban.

Essig cannot hide his horror that the story of the animals whose intelligence and usefulness he has described in his book has come to this, and in the final chapters there is much less scientific detachment and much more writerly horror. The problem with confining pigs, he says, is that cruelty is built into the system. Pigs are adaptable, says Essig, but even they cannot adapt to tiny crates, crowded pens, slatted floors and ammonia-saturated air. Essig's conclusion, based on compassion but science too, is that change must come. Some needs - the need to build a nest, to root, to nuzzle, to build social bonds -- should not be denied.