The arms race between the human immune system and gonorrhea might have had the useful side effect of promoting healthy brain tissue later in life.

This tiny boost to cognitive health in our twilight years might have played a small role in ensuring grandmas were sharp-minded enough for evolution to keep them around.

While it's fiendishly difficult – and may be impossible – to figure out what evolutionary factors are responsible for living beyond ages where we no longer reproduce, researchers at the University of California, San Diego, are closing in on some possible explanations.

In 2015, a team of researchers led by molecular medicine professor Ajit Varki discovered that humans have a unique type of immune receptor that protects against Alzheimer's disease and sets us apart from other primates.

In a paper published this month, the team found that the spreading of this variant immune receptor in our species wasn't entirely random, but rather the result of intense selection pressure over a relatively brief period.

The research showed that some of our closest relatives – Neanderthals and Denisovans – did not have this version of immune receptors coded into their genomes. Something drove humans to develop this special immune receptor early in our history as a species, the researchers said.

The likely culprits are infectious human-specific pathogens like Neisseria gonorrhoeae that try to disguise themselves by dressing in the same sugar coating as human cells, which fools patrolling immune cells into thinking the bacteria are harmless.

Gonorrhea got very good at tricking the human immune system into thinking it was just another human cell. But the human immune system found a way to fight back.

The researchers showed that the newly evolved immune receptor could see through the disguise and kill the invading bacteria, while the older variation of the immune receptor could not.

Getting rid of gonorrhea is useful for the survival of the species because this disease can mess with human reproduction.

The new version of the immune receptor is called huCD33. Thanks to the way this version is tweaked into two subtly different structures within our body, it's been the subject of investigations by evolutionary scientists for some time.

Once evolved, this immune receptor was probably co-oped by brain immune cells, called microglia, for a different purpose: protection against aging, the researchers suggest.

The human immune system usually doesn't attack itself on purpose, but it needs to when cells start to decay.

The huCD33 receptor, which seems to have evolved as a response to sneaky bacteria, had the added benefit of being able to recognize decaying brain tissue and thereby protect cognitive function in old age.

Microglia use the huCD33 receptor to clear away damaged brain cells and amyloid plaques associated with Alzheimer's disease. Whether this might have played a role in clearing the way for evolution to add a few more precious years to our lives for the sake of helping out with raising families is a topic open to debate.

Grandparents provide benefits to the human species as they help to look after kids and pass on important cultural knowledge. And gonorrhea may be to thank for that.

This paper was published in Molecular Biology and Evolution.