The last man on Earth is a common trope in fiction – but what if it actually happened? How many people would it take to save our species?

The alien predators arrived by boat. Within two years, everyone was dead. Almost.

The tiny islet of Ball’s Pyramid lies 600km east of Australia in the South Pacific, rising out of the sea like a shard of glass. And there they were – halfway up its sheer cliff edge, sheltering under a spindly bush – the last of the species. Two escaped and just nine years later there were 9,000, the children and grandchildren and great-grandchildren of Adam and Eve.

No, this isn’t a bizarre take on the story of creation. The lucky couple were tree lobsters Dryococelus australis, stick insects the size of a human hand. They were thought to be extinct soon after black rats invaded their native Lord Howe Island in 1918, but were found clinging on in Ball’s Pyramid 83 years later. The species owes its miraculous recovery to a team of scientists who scaled 500ft of vertical rock to reach their hiding place in 2003. The lobsters were named “Adam” and “Eve” and sent to start a breeding programme at Melbourne Zoo.

Bouncing back after insect Armageddon is one thing. Female tree lobsters lay 10 eggs every 10 days and are capable of parthenogenesis; they don’t need a man to reproduce. Repopulating the earth with humans is quite another matter. Could we do it? And how long would it take?

The answer is more than a whimsical discussion for the pub. From Nasa’s research on the magic number of pioneers needed for our move to another planet, to decisions about the conservation of endangered species, it’s a matter of increasing international importance and urgency.

The average person has between one and two lethal recessive mutations in their genome

So let’s fast-forward 100 years. Humanity’s endeavours have gone horribly wrong and a robot uprising has wiped us off the face of the Earth – a fate predicted by Stephen Hawking in 2014. Just two people made it. There’s no way around it: the first generation would all be brothers and sisters.

Sigmund Freud believed incest was the only universal human taboo alongside murdering your parents. It’s not just gross, it’s downright dangerous. A study of children born in Czechoslovakia between 1933 and 1970 found that nearly 40% of those whose parents were first-degree relatives were severely handicapped, of which 14% eventually died.

Recessive risks

To understand why inbreeding can be so deadly, we need to get to grips with some genetics. We all have two copies of every gene, one from each parent. But some gene variants don’t show up unless you have two exactly the same. Most inherited diseases are caused by these “recessive” variants, which sneak through the evolutionary radar because they are harmless on their own. In fact, the average person has between one and two lethal recessive mutations in their genome.

When a couple are related, it doesn’t take long for the mask to slip. Take achromatopsia, a rare recessive disorder which causes total colour blindness. It affects 1 in 33,000 Americans and is carried by one in 100. If one of our post-apocalyptic survivors had the variant, there’s a one in four chance of their child having a copy. So far, so good. After just one generation of incest, the risk skyrockets – with a one in four chance of their child having two copies. That’s a 1 in 16 chance that the original couple’s first grandchild would have the disease.

This was the fate of the inhabitants of Pingelap, an isolated atoll in the western Pacific. The entire population is descended from just 20 survivors of a typhoon which swept the island in the 18th Century, including a carrier of achromatopsia. With such a small gene pool, today a 10th of the island’s population is totally colour blind.

Even with these hideous risks in mind, if the survivors had enough children the chances are at least some of them would be healthy. But what happens when inbreeding continues for hundreds of years? It turns out you don’t have to be stuck on an island to find out, because there’s one community that just can’t get enough of their close relatives: European royalty. And with nine generations of strategic marriages between cousins, uncles, and nieces in 200 years, the Spanish Habsburgs are a natural experiment in how it all adds up.  

Charles II was the family’s most famous victim. Born with a litany of physical and mental disabilities, the king didn’t learn to walk until he was eight years old. As an adult his infertility spelled the extinction of an entire dynasty.

Genetic diversity allows species to evolve their way around future challenges

In 2009 a team of Spanish scientists revealed why. Charles’ ancestry was so entangled, his “inbreeding coefficient” – a figure reflecting the proportion of inherited genes that would be identical from both parents – was higher than if he had been born to siblings.

It’s the same measure used by ecologists to assess the genetic risks faced by endangered species. “With a small population size everyone is going to be related sooner or later, and as relatedness increases inbreeding effects become more important,” explains Dr Bruce Robertson from Otago University. He studies New Zealand’s giant, flightless parrots, called the kakapo, of which there are only 125 left on the planet.

Of particular concern are the effects of inbreeding on sperm quality, which has increased the proportion of eggs that will never hatch from 10% to around 40%. It’s an example of inbreeding depression, Robertson says, caused by the exposure of recessive genetic defects in a population. Despite plenty of food and protection from predators, the kakapo might not make it.

Immune mix

Endangered species also run the gauntlet of longer-term risks. Although they may already be well adapted to their environment, genetic diversity allows species to evolve their way around future challenges. Nowhere is this more important than immunity. “It’s something that most species seem keen to promote diversity in, even humans. We pick mates with a very different immune composition so our offspring have a diverse array of immune locks,” says Dr Philip Stephens from Durham University. Back in our evolutionary past, it’s thought that pairing with Neanderthals may have given our immune systems a genetic boost.

Even if our species makes it, it could be unrecognisable. When small pockets of individuals remain isolated for too long they become susceptible to the founder effect, in which the loss of genetic diversity amplifies the population’s genetic quirks. Not only would the new humans look and sound different – they could be an entirely different species.

So how much variety do you need? It’s a debate that goes right back to the 80s, says Stephens, when an Australian scientist proposed a universal rule of thumb. “Basically you need 50 breeding individuals to avoid inbreeding depression and 500 in order to adapt,” he says. It’s a rule still used today – though it’s been upped to 500-5,000 to account for random losses when genes are passed from one generation to the next – to inform the IUCN Red List, which catalogues the world’s most threatened species. 

Increasingly, the concept is leading those in the field to question the policies of large conservation charities, which prioritise the most endangered species. “It’s conservation framed in the context of triage – you sift casualties and ask is there a chance of saving them. It can be used to say well, can we forget about species?”

There are stories of incredible journeys back from the brink – anything is possible – Dr Philip Stephens

But before you write off our couple, as one scientist pointed out, we’re living proof of the concept’s inherent flaws. According to anatomical and archaeological evidence, our ancestors wouldn’t have made our own population targets, with 1,000 individuals in existence for nearly a million years. Then between 50,000 and 100,000 years ago, we hit another rough patch as our ancestors migrated out of Africa. As you would expect, we’ve been left with astonishingly low genetic diversity. A 2012 study of the genetic differences between neighbouring groups of chimpanzees found more diversity in a single group than among all seven billion humans alive today.

Looking to our ancestors may be our best bet. Anthropologist John Moore’s estimate, which was published by Nasa in 2002, was modelled on small migrating groups of early humans – around 160 people. He recommends starting with young, childless couples and screening for the presence of potentially dangerous recessive genes. Alas, Moore was contemplating long-term space travel, not repopulating the planet. His number only allows for 200 years of isolation before the pioneers head back to Earth.

So what of the last man and woman? It’s impossible to say with any certainty, though Stephens is tentatively optimistic. “The evidence for the short-term effects of low genetic diversity is very strong, but all these things are probabilistic. There are stories of incredible journeys back from the brink – anything is possible.”

As long as the apocalypse doesn’t destroy the foundations of modern civilisation, humanity could bounce back surprisingly fast. At the turn of the 20th Century, the Hutterite community of North America – which is, incidentally, highly inbred – achieved the highest levels of population growth ever recorded, doubling every 17 years. It’s a tough ask, but if each woman had eight children, we’d be back to seven billion people and our current population crisis in just 556 years. 

Follow us on Facebook, TwitterGoogle+LinkedIn and Instagram.

If you liked this story, sign up for the weekly BBC.com features newsletter, called “If You Only Read 6 Things This Week”. A handpicked selection of stories from BBC Future, Earth, Culture, Capital, Travel and Autos, delivered to your inbox every Friday.