The Romans had a phrase that summed it up nicely: mater semper certa est, pater semper incertus est. The mother is always certain, the father is always uncertain.

Now, researchers have found that some people have more reason to doubt their fathers than others, or at least have had over the past half millennium.

If the family tree is peppered with labourers and weavers who crammed into cities in the Industrial Revolution, a deep breath might be in order.

The scientists found that in western Europe over the past 500 years, births from extramarital couplings were as low as half a percent for farmers and the rural middle and upper classes – strata occupied by well-off merchants, lawyers, skilled craftsmen and the like.

But among the lower classes, populated with labourers and people without steady work, the rate of illegitimate births reached a peak of nearly 6% in the densely populated cities of the 19th century.

Maarten Larmuseau, who led the study at the Catholic University of Leuven, had anticipated more illegitimate children born into the higher echelons of society. After all, he notes, in paintings, plays and literature, dubious paternity controversies seem a particular affliction of the aristocracy. “I was surprised to see this signal so prominently,” he said. “It was not what I expected.”

Larmuseau decided to investigate historic rates of “extra-pair paternity” to see how different lives and times shaped the numbers. With help from genealogists, he gathered birth records and other civil documents that identified pairs of men living in Belgium or the Netherlands who shared a paternal ancestor as far back as the 15th century.

The study focused on 513 pairs of men who agreed to have their Y chromosomes tested. If they truly shared the distant male ancestor, they would also share a Y chromosome, because it is passed down exclusively from father to son. But if the men’s Y chromosomes differed, then at some point on the male line, someone’s father was not who they thought it was.

Writing in Current Biology, Larmuseau describes how birth rates from extramarital sex were stable over the 500 years, standing at about 1% for Belgium and the Netherlands, despite their religious differences.

But the rates varied widely across different groups. Class had the greatest impact, with the rate falling from 4% in the lower classes to 1% in the middle and upper classes.

Where people lived had an impact too. Added together with class, the rates shifted to 0.5% among well-off country folk to 6% among the poorest in bustling cities.

Larmuseau points out that it is impossible to be sure why the differences exist. Births outside marriage can be due to affairs, but also rape and sexual aggression. “We cannot interview these people, so we don’t know what happened,” he said.

From an evolutionary perspective, remaining faithful is not always an obvious strategy. Women can benefit from pairing up with higher-class men, but in sparsely populated rural areas there are fewer opportunities, and tight-knit communities make such liaisons harder to conduct. Working-class or peasant women would have less to risk, but at the same time, would have been more vulnerable to male aggression.

Given the findings, Larmuseau believes that people who buy DNA ancestry kits should be warned that they may learn some awkward family secrets. “These companies don’t offer counselling,” he said. “But it can be a trauma to find out that your father is not your father from a DNA test you bought to see if you have Viking DNA or are related to Richard III.”

Robin Dunbar, an evolutionary psychologist at Oxford University, who was not involved in the study, said the rates were roughly what one might expect, with higher rates among lower classes, where there is less at stake from paternity uncertainty, and in large conurbations, where there are more opportunities and less social policing. “It is impressive that the rates have remained so stable across such a long period during which major changes were taking place in society,” he said.