Hundreds of thousands of years ago, our ancestors evolved a simple trick that could have helped thwart a major infectious disease. It probably saved our skins, but the change was far from a perfect solution.

New research has uncovered evidence that mutations arising between 600,000 and 2 million years ago were part of a complex of adaptations that may have inadvertently made us prone to inflammatory diseases and even other pathogens.

An international team of researchers compared around a thousand human genomes with a few from our extinct cousins, the Neanderthals and Denisovans, to fill in missing details on the evolution of a family of chemicals that coat the human body's cells.

Sialic acids are a diverse group of carbohydrates that blossom like leaves from the tips of proteins covering the surfaces of human cells.

This canopy of sugars is typically the first thing you'd bump into if you were the size of a virus or bacterium, so it's no surprise that these chemicals serve as a security badge, identifying friend from foe.

Changes in sialic acid markers can give rise to a number of diseases. But it was one specific change particular to all humans that the researchers here were most keen to gain an understanding of.

Most mammals – including closely related apes – have a compound called N-glycolylneuraminic acid, or Neu5Gc. We've known for some time that the gene for this version of sialic acid is broken in us, leaving its precursor form, N-acetylneuraminic acid (Neu5Ac), to do its job.

Researchers previously speculated that this mutation was selected for in humans to make it harder for devastating malarial parasites such as Plasmodium knowlesi to latch onto red blood cells.

It's a swap that other animals – including a number of birds, bats, and even whales – have also evolved on their own.

Since chimpanzees retain the gene for Neu5Gc, the mutation must have occurred within the past 6 million years or so, sometime after we parted ways from one another.

This window can now be narrowed down even further. This most recent study shows Neanderthals and Denisovans share our variant of sialic acid, meaning the change happened before our branch of the family tree separated roughly 400,000 to 800,000 years ago.

Sialic acid markers are only part of the story, though. To differentiate between cells that belong to us from possible invaders, our immune cells are armed with a scanning chemical called sialic acid-binding immunoglobulin-type lectins. Or Siglecs for short.

When an inspection occurs, if a cell's sialic acid marker isn't up to scratch, it's curtains for that cell. Naturally, any changes to our sialic acid name-tag would imply our system of Siglecs would have needed adjusting as well.

Sure enough, on further investigation the researchers found significant mutations among a cluster of Siglec genes that are common to humans and their ilk, but not great apes.

Not all of these versions are found on immune cells, either. According to the study, some are found on other tissues, such as the brain, placenta, and gut.

This radical rewiring of our immune system is no small thing. If the malaria-hypothesis carries weight, it would have given Neu5Ac humans living in areas prone to the parasitic disease a huge advantage over their Neu5Gc relatives.

But it might have been a big price to pay. A decade ago, researchers from the same team suggested the mutation would have separated our ancestral communities, potentially preventing them from reproducing.

In other words, our species' lineage might have splintered as a result of this complex of immune mutations, possibly occurring with the emergence of Homo erectus a little more than 2 million years ago.

But there are other consequences of the change we're still experiencing today.

Siglec expression is linked with conditions such as asthma and Alzheimer's disease, raising the possibility that protection from a devastating disease put us at risk of other conditions.

As for that swap in sialic acid, it might have provided a new opportunity for a slew of other pathogens.

A wide variety of viruses and bacteria gain entry to our cells by grabbing onto the fuzz of sialic acid, many of which infect humans but not apes. Many, such as cholera, smallpox, influenza, and coronaviruses, are far from trivial.

"Most coronaviruses infect cells in two steps – first by recognising abundant sialic acids as binding sites to gain a foothold, and then seeking out the higher affinity protein receptors like ACE2," physician Ajit Varki told Science magazine's Ann Gibbons.

Strangely, a human-like elimination of the NeuA5c gene in mice gives them a boost in running ability, and in activating other parts of their immune system. Given the new cognitive and physical talents emerging in humans a couple of million years ago, asthma and cholera might well have been worth the swap.

Evolution gets the job done. But nobody said it was perfect.

This research was published in Genome Biology and Evolution.