Allergy to cow's milk is not well understood*. It is known that the phenomenon is more common in children than adults and that it generally goes away as a child grows up. As one might suspect in our age of hypochondria, parents who think their child has a milk allergy are far more common than parents who have a child with an actual milk allergy.
In an effort to understand how cow's milk allergies (CMA) form, an interdisciplinary team of scientists investigated if there is a link between certain kinds of sugars found in a mother's breast milk and the presence of CMA in her infant. To determine this, they analyzed the breast milk of 39 mothers who had a baby with CMA and 41 mothers who had one that did not.
They found that infants with CMA were likelier to be fed breast milk that lacked a sugar called lacto-N-fucopentaose III (LNFP III).
How the absence of this particular sugar could be linked to cow's milk allergy is unclear. The sugar is not absolutely required to prevent CMA. However, its molecular structure might provide a hint. LNFP III may interact with a receptor called DC-SIGN on the surface of dendritic cells, a cell that plays a role in both turning on and off the immune response. Possibly, LNFP III turns off the immune response by teaching dendritic cells to "tolerate" it as well as other similar structures. According to this hypothesis, children who are exposed to LNFP III in their mother's milk would be less likely to develop an allergy to cow's milk.
Alternatively, LNFP III is just an accidental bystander and some other undetected molecule is to blame for CMA (or the lack thereof). The search for an explanation continues.
Source: Antti Seppo, Chloe Autran, Lars Bode, Kirsi Järvinen. "Human milk oligosaccharides and development of cow’s milk allergy in infants." J Allergy Clin Immunol. Article in press. DOI: http://dx.doi.org/10.1016/j.jaci.2016.08.031
*Note that cow's milk allergy and lactose intolerance are not the same thing. Cow's milk allergy is relatively uncommon in adults, while lactose intolerance is extremely common. In fact, most adults are lactose intolerant.