Why Does Cutting an Onion Make Your Eyes Produce Tears?
An intact onion keeps the ingredients for its chemical defense separated inside its cells. Cutting it brings those ingredients together.
Onions absorb sulfur from the soil and use it to produce several compounds involved in flavor and defense. When a knife ruptures the cells, enzymes encounter substances that were previously stored apart. A rapid sequence of reactions begins, producing a volatile compound called syn propanethial S oxide.
Because the compound evaporates easily, it rises from the cutting board and reaches the surface of the eyes. There it activates sensory nerves that detect irritation. The nervous system responds by ordering the tear glands to release fluid, attempting to dilute and wash away the intruder.
For many years, scientists thought the tear producing compound formed spontaneously as part of the same chemical pathway responsible for an onion’s flavor. In 2002, Japanese researchers identified a separate enzyme, lachrymatory factor synthase, that directs the reaction toward the eye irritating substance. This discovery later helped researchers develop onions that produce fewer tears.
A sharper knife may reduce irritation because it crushes fewer cells, although it cannot stop the chemistry completely. Air movement can also carry the vapor away before it reaches the eyes.
The onion is not targeting human cooks specifically. Its response evolved to make damaged tissue less pleasant to animals and other threats. Our tears are the visible result of encountering a defense system activated by the first cut.
Source: An Onion Enzyme That Makes the Eyes Water, Nature - Why Does Chopping an Onion Make You Cry, Library of Congress

Head of a Greater Flamingo (Phoenicopterus roseus)
Source: By Luc Viatour