An international team of scientists say they have unearthed the answer in the DNA of ancient teeth and bones.
The genes which protected our ancestors from animal diseases now raise the risk of multiple sclerosis (MS).
The researchers call their discovery "a quantum leap" in understanding the evolution of the disease.
And they say it could change opinions on what causes MS, and have an impact on the way it is treated.
There are about twice as many cases of multiple sclerosis per 100,000 people in north-western Europe, including the UK and Scandinavia, compared with southern Europe.
Researchers from the universities of Cambridge, Copenhagen and Oxford spent more than 10 years delving into archaeology to investigate why.
MS is a disease where the body's own immune cells attack the brain and spinal cord, leading to symptoms like muscle stiffness and problems walking and talking.
They discovered that genes which increase the risk of MS entered into north-western Europe about 5,000 years ago via a massive migration of cattle herders called Yamnaya.
Our ancestors lived alongside animals, such as cattle and horses
The Yamnaya came from western Russia, Ukraine and Kazhakstan, and moved west into Europe, says one of four Nature journal papers published on the topic.
The findings "astounded us all", said Dr William Barrie, paper author and expert in computational analysis of ancient DNA at University of Cambridge.
At the time, the gene variants carried by the herding people were an advantage, helping to protect them against diseases in their sheep and cattle.
Nowadays, however, with modern lifestyles, diets and better hygiene, these gene variants have taken on a different role.
In the present day, these same traits mean a higher risk of developing certain diseases, such as MS.