When a trait confers a selective benefit, i.e. increases the likelihood that someone who has the trait will have more children who reproduce themselves, it increases its share of the gene pool. Few traits have been more powerfully selected for in recent history than lactase persistance.
Pretty much all children can tolerate the lactose in milk, but for individuals who lack lactose persistence genes, drinking unprocessed milk will make you feel "off" and give you the runs. It is hardly a deadly consequence, but it makes drinking milk without processing it into yogurt or cheese to remove the lactose (which provides about a third of the calories in milk and takes additional effort) a not very viable source of nutrition.
Ancient DNA samples reveal that this trait was almost entirely absent in Europe's first wave Neolithic populations. It appears to have arisen someplace in Northern Europe after dairy farming became common. By the end of the Bronze Age, lactase persistence was predominant and lactose intolerance was rare in most European populations.
Clearly, this gene conferred a very powerful selective benefit (or was in close association with something else that conferred such a benefit) in the Copper and Bronze Ages of Europe. But, what exactly was the benefit?
Needless to say, lactase persistence is a trait that doesn't confer much selective advantage before cows are domesticated and dairying become common. An ability to digest milk properly doesn't matter if you have no regular source of milk in your diet.
But, John Hawks hypothesizes that the populations subject to selection, like many third world populations today, was perennially malnourished. In those conditions, once dairy farming was invented, lactase persistent women, due to their increased calorie consumption from milk, are able to bear children about two years earlier and to space their children about three months closer. Thus, lactase persistent women can have one or two more children per lifetime than women who are not, an increase of at least 10% per generation in lifetime fertility.
This may seem modest, but iterated over the thirty-four generation span of a thousand years, this means that populations with lactase persistent women will increase 25 times as rapidly as populations in which women are not lactase persistent. For example, if the population initially consisted of 1 lactase persistent woman for every 25 lactose intolerant women in 3000 BCE, this advantage would shift to the balance to 1 lactase persistent woman for every lactose intolerant woman by 2000 BCE, and to 25 lactase persistent women for every lactose intolerant woman by 1000 BCE. Thus, a 10% lifetime fertility benefit per woman per generation is enough to shift the lactase persistence trait frequency in the population from 3.8% to 96.2% in two thousand years, which is a pretty decent approximation of the change in the frequency of the lactase persistence trait in selected European populations in the time period from 3000 BCE to 1000 BCE.
If there were other fitness benefits in addition to fertility to lactase persistence, such as improved disease immunity, or an increased chance of survival during fairly frequently periods of famine, then the selective benefit would have been even greater.
Of course, there are only certain conditions where lactase persistence confers a strong benefit. As food production gets more reliable and abundant, and the number of calories available per person rises and the marginal benefit of improved nutrition from access to calories from lactose in milk declines.
Thus, it is not surprising that lactase persistence conferred more of a benefit (and hence became more predominant) in Northern Europe, where climate conditions were less well suited to the Fertile Crescent Neolithic package of crops, than in Southern Europe, where the Mediterranean climate was a near perfect match for the circumstances in which these crops were domesticated.
Likewise, it is not surprising that the selective benefit of lactase persistence declined over time as agricultural technologies became more advanced and well adapted to local conditions.
The declining selective advantage is also a function of the logic of the S-shaped logistic curse in which fitness enhancing traits first remain rare due to the small base number of the exponentially growing group, then accelerates, and then slows down again at the tail end of the transition because most people have already transitioned. When almost everybody can process lactose in milk, sparing a little extra food for the people who cannot process it is easier for a community to manage than it is when almost nobody is lactase persistent, so the relative benefit of lactase persistence in the population declines.