We think of it as the most natural of activities. Yet sex, as a method for perpetuating a species, is remarkably inefficient and has huge biological costs. Steve Connor explores a scientific mystery

Why do we have sex? There are perhaps as many answers as there are meanings to this question. We have sex because we like it, or because it cements an emotional bond between two people. We also have sex if we want babies. But, strange as it may seem, the question of why males and females need each other for reproduction has really never been answered satisfactorily. What exactly is sex for?

Of course, sex and reproduction go together. Biologically speaking, sex is a means of sharing genetic information between male and female in the creation of a new individual – the baby. So the purpose of sex is to mix up genes in the act of reproduction.

But although sex is inextricably linked with reproduction, we also know there are many species of plants, animals and microbes that happily reproduce without sex. Take greenfly for example. They spend most of their time replicating themselves without sex. For much of the spring and summer they consist almost entirely of females that busily clone themselves by giving birth to their genetically identical daughters, who incidentally contain within their tiny bodies the embryos of the mother aphid's grand-daughters. This form of asexual reproduction (called parthenogenesis) continues without any sort of male intervention and, as any gardener can attest, its efficiency is astounding. Within days, a rose bush can be carpeted in the cloned progeny of a single female. And here lies the great paradox of sex. As a form of reproduction it is remarkably inefficient compared to asexual reproduction. Indeed, sex as we understand it – the fusion of sperm and egg – is actually the antithesis of reproduction because, in sex, two cells fuse to form one cell. More importantly, sex comes at an enormous biological cost and some of the greatest minds in evolutionary biology have struggled to explain how sex can pay for this cost.

For much of the 20th century it was thought that the problem of sex had been solved. Variety was the solution to sex. The advantage was seen simply as a way of shuffling the genes and creating genetically variable offspring that would be different to their parents. It was seen as a more preferable system to the cloned similarities of asexual aphids.

But in the 1960s some evolutionary biologists pointed to a huge flaw in this argument. Yes, sex produces variety that might be important in the future, but the immediate problem is that in the short term an asexually reproducing individual can outbreed its sexual rival. In other words, although sex was good for the species, asex was better for the individual – which fitted the selfish gene model of Darwinian evolution.

The late John Maynard Smith, one of the greatest Darwinian thinkers of the late 20th century, explained what became known as the two-fold cost of sex by imagining a typical sexual species of lizard. Each female lays on average 100 eggs during her lifetime in the normal 50:50 ratio of male to female. On average, only two of these eggs will survive into adulthood and again on average one will be male and one will be female.

Now suppose a mutation occurred in this species that allowed females to reproduce by parthenogenesis – an unfertilised egg can develop directly into an embryo without sperm. Again, the female will on average lay 100 eggs, but this time they will all be female and the two survivors will both be females capable of parthenogenetic reproduction. As Maynard Smith pointed out, within a few generations this asexual mutant will quickly overrun the sexual form of the lizard because it will produce twice as many egg-laying females as the sexually reproducing lizard. "Thus there is a two-fold advantage associated with parthenogenesis, or, equivalently, a two-fold cost of sex," he explained.

The problem is also about questioning the need for males. While in many species, males spend time and resources helping to rear their offspring, there are many species – humans included – where males contribute little or nothing to the future wellbeing of their offspring, other than donating the single sperm cell that fertilised the egg. So in these cases, what is the purpose of males? Or, as a scientifically literate feminist might phrase it, what are men for?

To answer this is to answer the biggest question in biology. As Maynard Smith explained in an interview shortly before his death in 2004: "The evolution of sex is the hardest problem in evolutionary biology. When it happened, how it happened, why they did it in the way they did. There are still features of the way they do it that seem very odd to me."

In its broadest sense, sex is a process resulting in offspring with genes from two different ancestors. Some bacteria simply swap bits of genetic material between themselves in a primitive form of sex. This is thought to be how early forms of sex began hundreds of millions of years ago when all life on Earth consisted of single-celled organisms. It was all about swapping bits of genetic code.

This primitive sex may have been a useful way of covering up your deficiencies by merging your genetic information with another individual. "It's what I call the engine and gearbox theory of the origins of sex," Maynard Smith said. "If you buy two clapped-out Minis, one with no engine and one with no gearbox, you can make one functional Mini. I have the feeling that sex originated on that principle; two cells, both with deficiencies, fused and they cover up the deficiencies."

A narrower definition of sex, however, is the one that we are interested in. This involves the creation of special sex cells – the sperm and the egg – along with the sexual differentiation of a species into male and female. Evolutionists have shown that the sperm and the egg represent two opposing strategies in sexual reproduction. The male produces lots of small, mobile sex cells – the sperm – each with little individual investment in terms of resources. The female produces a smaller number of relatively larger sex cells, the egg, complete with a heavier investment in terms of nutritional resources.

The female invests more in each of her eggs than a male invests in each of his sperm. She therefore guards her eggs more closely and needs to be choosy about which sperm she allows to fertilise them. The male approach, meanwhile, is to fertilise as many eggs as possible. This basic imbalance in genetic investment, due to differences in reproductive strategies, led to a sort of runaway evolutionary divergence between the sexes. This may partly explain many of the physical and emotional differences between men and women – from breasts to the tendency towards infidelity.

But the central point about a sperm and an egg is that they are both unlike every other cell in the body – they have just one copy of each chromosome. Except for the Y and X sex chromosomes, every other cell has two copies of each chromosome, one from the mother and one from the father, making 46 in total – two sets of 23. However, when sperm and eggs are made by a special process of cell division called meiosis they lose one set of chromosomes. So instead of having 46, they have 23. It is only when the sperm and egg come together as a fertilised egg that the magic number of 46 is restored.

Meiosis involves a process of gene shuffling called genetic recombination. It's rather like each cell having two packs of cards representing the genes from each of their parents. After meiosis, the sperm or egg ends up with just one pack, but with this single set of cards drawn at random from each of the packs inherited from their mother and father. The randomness of this shuffling process partly explains why some children are the spitting image of one or other of their parents – or even grandparents – while some are a blend of both.

This process is so important to sex that meiosis takes place in just about every organism that produces sperm and eggs, from dandelions to dolphins. Indeed, Maynard Smith believed it is inconceivable that such a complicated process, common to all strands of life, would have originated twice in the history of life on Earth.

The whole point of meiosis is in providing a mechanism to produce genetic variety. And however the enigma of sex is described, whether it is the paradox of sex or the cost of producing males, the answer to the question of what sex is for must lie in this variation, which is the most obvious difference to the efficient, asexual way of reproduction shown in parthenogenetic females.

Are we any closer to explaining how the twofold cost of sex is redeemed? Saying that it is down to genetic variation is not enough. Some evolutionary biologists have attempted to explain that sex and the genetic recombination in meiosis is a way of covering up bad mutations carried in both parents, allowing the offspring to emerge rejuvenated and freed of the genetic shackles of the previous generation. Others believe it is a way of bringing together two sets of good mutations in one individual.

Both of the explanations can be seen as variations of Maynard Smith's "engine and gearbox" theory. And both lack convincing evidence to show they can fully explain the paradox of sex.

But the theory that has gained some of the strongest support is the one put forward by another now dead evolutionist, William Donald Hamilton, who died on an ill-fated expedition to the Congo in 2000. Hamilton approached the problem not so much as why did sex evolve, but why it hasn't been eradicated. The phrase "evolution of sex" is misleading, he once wrote, because the problem really revolves around the evolutionary maintenance of sex. "This is because what we are almost all primarily concerned with... is why sex doesn't disappear," Hamilton wrote.

He believed that sex exists, and continues to exist, because of an ever-lasting struggle between hosts and parasites. Sex is a way of developing new genetic weapons in the continual arms race against disease.

"The essence of sex in our theory is that it stores genes that are currently bad but have promise for the future. It continually tries them in combination, waiting for the time when the focus of disadvantage has moved elsewhere," Hamilton explained. The reason why sex continues, and has continued for so long, is that the struggle with parasites and disease is one that also never ends, and never gets any easier.

So sex is there to be enjoyed, to provide a physical bond with a partner and for producing babies. But it may also be true that the reason why we have sex today is because it helped to keep our ancestors healthy and disease free in the past.