The short answer
Early humans did not avoid inbreeding perfectly, and the evidence for what they did is indirect. The most likely explanation is that several habits worked together: marrying people from outside their own group, moving between groups, following social rules about close relatives, and being less drawn to people they grew up with. Their populations were also larger than the smallest groups people often picture.
Small groups, but not isolated ones
Many anthropologists describe hunter-gatherer societies as living in small bands, often a few dozen people, that moved with the seasons. A band was not a sealed-off unit, though. Neighboring bands traded, shared resources and met at gatherings, which gave people chances to find partners from elsewhere.
Marrying outside the group
Marrying someone from outside one’s own group, called exogamy, is common across human societies. Many cultures have rules about who counts as an acceptable partner. These rules often rule out close relatives and sometimes require marriage into a different band, village or clan. The exact rules vary widely, and not every society has them in the same form.
Moving between groups
Many human societies have a pattern in which one partner moves to live with the other’s family or group after marriage. In patrilocal societies, wives move to their husband’s group. In matrilocal societies, husbands move to their wife’s group. Either pattern tends to place spouses from different families, which makes marriage between close relatives less likely within a group.
Familiarity from early life
People raised together in early childhood tend not to develop sexual attraction to each other later. This idea is often called the Westermarck effect, after the Finnish anthropologist Edvard Westermarck, who described it in the 1890s. Studies of children raised together on Israeli kibbutzim, for example, found that few of them later married one another. This is consistent with the idea, although researchers still debate how strong the effect is and why it happens.
How many people were available to mate
Estimates from genetic data suggest that the effective population size of our ancestors, meaning the number of individuals who contribute to the next generation’s genes, was in the thousands or more for much of our history. These estimates differ and are still debated. Within a population that large, a randomly chosen partner is unlikely to be a close relative.
Discussions of this topic often lead to the question “What size population do you need to avoid inbreeding?” There is no single answer, because the risk depends on how many individuals breed, how they choose mates, and how the group is structured.
Mixing with other human groups
Modern people carry DNA from other ancient groups. On average, people with ancestry outside Africa carry roughly 1 to 2 percent Neanderthal DNA, and some populations in Oceania carry DNA from the Denisovans, another group of archaic humans. Such mixing added genetic variety that was not available within any single group.
What this suggests
Taken together, the evidence suggests that early humans kept inbreeding low through a mix of social rules, movement between groups and early-life familiarity, rather than through one single method. Close-relative matings were probably not impossible, and some families or small groups may have had more of them than others. Because much of the evidence is indirect, specific claims about any one group should be treated with care.