cow cute!
Consuming milk from a mother is one of the defining features of being a mammal, and to achieve this, mammalian infants have an enzyme known as lactase, which breaks down the primary sugar in milk (lactose) into glucose and galactose.

After weaning, mammals normally see a reduction in lactase production until levels are very low in adulthood, a trait known as lactase non-persistence (LNP). However, many human adults have the ability to produce lactase throughout life, known as lactase persistence (LP), which makes us unique among mammals. LP is associated with cultures that have high levels of milk consumption, which led to the "cultural-historical hypothesis": basically, that those with LP were fitter, had more offspring and eventually dominated milk-drinking regions. Although largely explaining observed patterns, there are a few exceptions which I'll touch on later.

To start off, we'll be focusing on a major basis for LP evolution: the negative side effects of milk consumption in the majority of adults.

The side-effects: bacteria and the gut.

the gut intestive colon appendix liver stomach
© Pearson Scott Foresman
The human digestive tract
Food is mixed and proteins are broken down in the stomach. Then the food-mush enters the small intestine which facilitates digestion by enzymes like human lactase. Finally, the large intestine absorbs water and salts, and the many bacteria it contains consume the undigestable material (including lactose, for LNP individuals who have no lactase).

After leaving the stomach, the lactose in milk first reaches the small intestine. If human lactase is present, it will break the lactose down into glucose and galactose, which in turn are released into the blood. However, if no human lactase is present, as in LNP individuals, the lactose travels into the large intestine, where it is eventually consumed by local bacteria.

Depending on the species, the bacteria release a combination of carbon dioxide, hydrogen and methane - often leading to a mix of bloating, flatulence and constipation. Further worsening matters, before it is consumed, the lactose can cause osmotic shock in the large intestine: with the resulting water gradient causing diarrhoea.
It's important to note that the symptoms discussed above, and LNP symptoms generally, are distinct from allergy to dairy milk proteins; which is not related to lactase production.
If early societies became dependent on milk as a source of nutrition, it would make sense that LP individuals would be better off. Around 33% of humans today display LP, but where are these milk consumers found?

LP in different parts of the world.

Distributions of lactase persistence map
© Map built by Joe Roe using data from the Global Lactase persistence Association Database LAD).
Distributions of lactase persistence (LP) among indigenous populations of the "Old World", displayed as a percentage of total population. Regions of high LP are displayed in darker blues.
By the 1980's, scientists had a good idea that LP was heritable, and by the early 2000's, the first associated single nucleotide polymorphism (SNP) was found in populations of Eurasian descent - with a later 4 more SNPs discovered in populations of African descent.
SNPs are single nucleotide base changes (like A to T, or C to G) which can result in an alteration of a gene, or if in a regulatory region, can change its expression pattern. In the case of LP, the SNPs result in enhanced expression of lactase into adulthood.
Further analysis of the different SNPs lead to the conclusion that they arose independently in multiple regions and increased in frequency in the last 2000-10000 years. The highest distributions of LP can be found in populations of European, East African, West African and Middle Eastern descent (up to 90% LP), and the lowest distributions in East Asia, Australasia and Southern Africa.

Historically beneficial to consume milk?

The postitive selection of LP is estimated to be among the strongest on the human genome, with similar values to alcohol tolerance, but it is not entirely clear as to how this strong selection pressure came about. It has been argued that the nutritional benefit of milk consumption, including increased calcium, vitamins, protein and glucose, were essential in pastoralist societies highly reliant on a handful of food crops. If an individual was LNP but reliant on milk for nutrition - side-effects like diarrhoea could be deadly. Other theories suggest milk drinkers benefited from increased vitamin D acquisition in the low-UV northern latitudes; and that milk could've been an essential source of electrolytes and hydration in arid regions of the Middle East and Northern Africa.

However, there are several populations which consume milk products but display low levels of LP. One reason for this could be a reliance on milk processing, which reduces the lactose levels almost entirely (as the bacteria used to make yoghurt and cheese consume the lactose). As such, in regions where climatic or cultural practices encouraged processing, there may have been lower selection rates for LP. This is likely a large factor in the reason behind the observed low rates (often <10%) of LP in dairy consuming regions of NE and SE Asia, and also may contribute to the lower levels of LP in the hotter regions of Southern Europe and Northern Africa.

Another interesting finding revolves around LP in certain isolated African regions with no historical milk consumption, with some populations having 50-70% LP. It is not really understood why, but some researchers have suggested that lactase may play a role in the digestion of other molecules too, and as such LP would have other benefits outside of lactose breakdown.

Textbook natural selection?

The development of lactose tolerance is a fine example of natural selection at work, even though the intricacies of the selection are not yet fully understood. We know for sure that over 10000 years ago, LP individuals, if present, represented an insignificant portion of the population. Today, in historical dairy regions, lactose tolerance exceeds 90%.

That's a massive change in a relatively short period of time: providing a clear illustration of the power of selective pressures to change population traits.

This post was based largely off two recent reviews: Swallow (2015) and Ségurel and Bon (2017).