In the distant past humans were much more free with our affections, but once our ancestors had settled down to farming, playing the field fell out of fashion

On first glance, sticking with one partner for life seems like quite a bad idea, at least from an evolutionary point of view.

Sperm is plentiful and does not take long to make, so it would not benefit a male to invest in only one female, who will take a long time to reproduce.

If monogamy is not that useful, why did it become a favoured way of life in so many cultures?

A female can also benefit from having a variety of partners. If her children have different fathers, some might be better protected if a disease comes along.

For these reasons, monogamy is extremely rare among mammals and many other animal groups, as BBC Earth recently explained.

The same is true of human societies, many of which permit taking several spouses, or "polygamy". One estimate suggests that 83% of cultures allow it – although admittedly, even in these supposedly polygamous cultures, most people live in monogamous pairs, if only because they cannot afford more than one spouse.

So if monogamy is not that useful, why did it become a favoured way of life in so many cultures?

A new analysis provides a possible reason. A team of researchers, writing in Nature Communications, says that sexually-transmitted infections (STIs) could have been a powerful driving factor in forcing expanding societies to practice monogamy.

If you think a behaviour is not acceptable, you have to spend time protesting

When humans changed from a hunter-gatherer way of life to a more settled farming lifestyle, over 8,000 years ago, monogamy became increasingly common. Polygyny, a form of polygamy in which a man takes several wives, was slowly phased out, the team says.

They argue that this change in lifestyle was socially imposed. This would have taken a lot of time and energy.

"If you think a behaviour is not acceptable, you have to spend time protesting and put effort into trying to develop social institutions or impose norms," says lead author Chris Bauch at the University of Waterloo in Canada. For instance, to prevent crime we have to fund a police force.

With Richard McElreath of the Max Planck Institute for Evolutionary Anthropology in Germany, Bauch sought to understand why humans might impose the norm of monogamy on others in their group.

It turns out that in the smaller populations these STIs aren't able to establish

"The reason this is interesting is that we appear to have practiced more polygyny in the past, but at the beginning of agriculture the presence of socially-imposed monogamy appeared to increase," he says.

His theory goes like this. In a small hunter-gatherer society of about 20-30 mature adults, STIs were not a major threat. Even if a few were doing the rounds, over evolutionary time they would not have had the opportunity to travel far. Instead they would eventually die out.

"It turns out that in the smaller populations these STIs aren't able to establish," Bauch says. "Groups are too small, and they disappear because of chance events after enough time."

However, in agricultural societies the populations rapidly expanded, so an infection in a polygynous group would quickly spread and become endemic. A critical mass of people would ensure STIs stay around.

That, Bauch and McElreath argue, is why it makes sense that large societies would favour monogamy. By punishing the non-monogamous, they are punishing those who contribute to the spread of disease.

An outbreak of syphilis, chlamydia or gonorrhoea could lead to infertility

Bauch and McElreath used a computational model to simulate what might happen to large populations with lots of STIs. "It's basically simulating all the population and defining the rules they obey, how individuals mate and how the disease spreads," says Bauch.

While we can treat many STIs today, in the past they could be devastating. Our ancient relatives did not have access to modern medicine, so an outbreak of syphilis, chlamydia or gonorrhoea could lead to infertility, or worse.

Others suggest a more potent driving force in monogamy is parental care.

In 2013, Kit Opie of University College London and colleagues published a study suggesting that monogamy was crucial for reproductive success. They also argued that monogamy has rather sinister origins.

If a male stays with the children he fathers, he can protect them from rival males – who might otherwise kill them so that their mothers become fertile again.

For these cheaters, STIs would not be a high cost

"Males who don't stick around have a low reproductive success because rivals come in and kill the infant," says Opie. "It's not good for the females, but disastrous for the males."

In other words, Opie says that the prevention of infanticide has been the driving force for monogamy. He is not convinced by Bauch and McElreath's findings.

"I can understand theoretically that STIs could have some kind of impact in reducing extra-pair copulation, but that it should bring about socially-endorsed monogamy doesn't seem likely to me," says Opie. "Their modelling is not based on realistic assumptions."

Issues of inheritance may also have played a role, according to a 2009 study.

Land became increasingly scarce in agricultural societies. Splitting it up among numerous heirs would reduce its value. Social monogamy provided a solution, as only true heirs would inherit their parents' estate.

We can imagine that multiple mechanisms may have supported the origin of monogamy

"Monogamous marriage emerged in Eurasia following the adoption of intensive agriculture, as ownership of land became critical to productive and reproductive success," the authors wrote.

Another factor not assessed in the new model is what would happen to "cheaters"; men without a partner who have sex with as many women as they can. Dieter Lukas of the University of Cambridge in the UK would be interested to see the effect.

"For these cheaters, STIs would not be a high cost, as they would be siring many offspring before an STI would make them infertile or kill them," he says.

There are several other ideas that could explain why monogamy evolved, including female competition and guarding a mate from rivals.

Whichever it was, Bauch says they need not contradict his new theory. "We can imagine that multiple mechanisms may have supported the origin of monogamy," he says – particularly when you consider how diverse human cultures are.

Modern societies have found more effective ways of reducing the risk of STIs, in particular the use of condoms. Programmes that only encourage abstinence before marriage have proven ineffective.

Melissa Hogenboom is BBC Earth's feature writer. She is @melissasuzanneh on Twitter.

Follow BBC Earth on Facebook, Twitter, and InstagramIf you liked this story, sign up for the weekly bbc.com features newsletter.