Answer: because of a chemical solution in the onion that stings the eyes.
The chemistry of an onion is strangely complex. When you cut an onion, you set off a series of chemical reactions. Millions of cells rupture, a gas is formed. Called propanethial oxide, this volatile gas vaporizes, rises and reaches the vicinity of your eyes. The gas contains sulphur which reacts with water. On contact with the tear fluid that coats and protects your eyes (composed mainly of water), the sulphur turns into propanesulfonic acid, which is as irritating as sulfuric acid.
Can you imagine what happens next? It stings! The reaction of the eye is to cry tear fluid to get rid of this chemical solution that is stagnant in your eyes. The problem is that an overabundance of water going up into our eyes creates a chain reaction: sulphur turns into sulphuric acid on contact with the tear fluid. It stings even more and so we cry all the more until all the gas escapes from the onion.
The solution to avoid this embarrassing situation that can cause itching, burning or simple tears is simple: cut the onion close to a trickle of water. The gas released during cutting is trapped and cannot reach your eyes. Another more radical solution is to protect your eyes with a diving, ski or welding mask. I am sure you will choose the first solution 🙂