A defence system in separate packets
An onion at rest is harmless, because its tear-making machinery is kept in pieces. Inside its cells, sulfur-rich compounds sit in one compartment while enzymes — the proteins that run chemical reactions — wait in another. Nothing happens while the cell walls hold.
Your knife changes that. Each slice crushes cells and mixes the separated ingredients, and the enzymes immediately get to work, converting the sulfur compounds through a short chain of reactions. The end product of the chain is a volatile gas with the tongue-twisting name syn-propanethial-S-oxide. Its job, from the onion's point of view, is to make the creature eating it regret starting.
From knife to tears
Being volatile, the gas escapes from the cut surface and drifts upward — conveniently, straight toward the face of the person doing the chopping. When it reaches your eyes it dissolves in the thin film of tears that coats them, and there it forms a mild acid that stings the eye's surface nerves.
Your body responds instantly and sensibly: the tear glands flood the eyes to wash the irritant away. The tears are not a malfunction; they are a cleaning system working exactly as designed — triggered, in this case, by a vegetable's chemical burglar alarm.
Outwitting the onion
Every popular countermeasure attacks a step in the chain. Chilling the onion first slows its enzymes and makes the gas less eager to evaporate. A very sharp knife crushes fewer cells, so less gas is made. Cutting under a trickle of water, or with a fan blowing across the board, carries the gas away or dissolves it before it reaches your eyes.
Breeding offers the permanent fix: onions vary naturally in their sulfur content, which is why 'sweet' onion varieties are gentler, and researchers have produced tearless onions by switching off the enzyme that makes the gas — proof that we understand the chain link by link.

