The answer begins in the soil. Onions are part of the plant genus Allium, along with garlic, chives, leeks and about 400 other cousins. These vegetables absorb sulfur in the earth, which helps form a class of volatile organic molecules called amino acid sulfoxides. These sulfoxides are the real tear-jerkers when onions go under the knife.
And what can we do to avoid the tears? Freezing an onion for 20 minutes, or wearing goggles (or even sunglasses!) will reduce the gas' interaction with the eyes. Classy!