Why does cutting onions cause tears?​
Interesting question! The cause of tears and itching is the chemicals produced by onion (Allium cepa). Lets go into some details.

Onions, coming from the family Liliaceae (also containing garlic, chives, scallions and leeks) store compounds known as amino acid sulfoxides, and the one we are talking about here is S-1-propenyl-L-cysteine sulfoxide (abbreviated as PRENCSO), also calles isoalliin (due to its similarity with alliin found in garlic). When onion is damaged (cut, chewed, etc.), an enzyme alliinase converts PRENCSO into 1-propenyl sulfenic acid. This compound is then converted into propanethial-S-oxide by an enzyme lachrymatory factor synthase (earlier this reaction was considered spontaneous). The reaction looks like this:



Propanethial-S-oxide is the major cause of the flavor and aroma of onion. However, it is a volatile compound i.e. vaporizes very quickly. When its vapors reach the eye, it causes tears because of being a lachrymator (aka tear gas) i.e. as soon as it comes in contact with cornea, it triggers a nervous response which leads to activation of lachrymal (tear) glands.

PS: when propanethial-S-oxide comes in contact with cornea, a small amount of it reacts with water to form sulfuric acid. This sulfuric acid is the cause of itching and irritation in eyes due to onion. Also, scientists are now trying to genetically either modify or stop the production of lachrymatory factor synthase enzyme to produce tearless onions. This (modification) has even been achieved to a high efficiency, as another answer discusses. However, making tearless onions could prove harmful to the crop in several ways, as discussed here.

EDIT: As asked in comments, I will add some details about how the sulfuric acid is produced from the reaction between propanethial-S-oxide and water.

The only resource I could find giving some details about this was Marta Corzo-Martínez, 2014. They summarize the complete pathway in the following diagram:



After applying some common chemistry principles, the concerned reaction turns out to be:

$\ce{4~C_3H_6SO~+~4~H_2O \rightarrow 4~C_3H_6O~+~H_2SO_4~+~3~H_2S}$

As you see, one of the products of hydrolysis of propanethial-S-oxide is hydrogen sulfide ($\ce{H_2S}$). Just like $\ce{H_2SO_4}$, $\ce{H_2S}$ also causes irritation in the eyes (its effect on eyes has been well documented, see Lambert et al, 2006 as an example). Thus, the produced $\ce{H_2S}$ only increases the irritation and itching in the eyes caused due to $\ce{H_2SO_4}$.

BONUS: Another interesting point here is runny nose. propanethial-S-oxide is actually the compound responsible for the smell and flavor of onions. But, it causes tears by exciting the lachrymal glands i.e. reflexive lachrymation. propanethial-S-oxide excites the trigeminal nerve (the fifth cranial nerve) causing activation of lachrymal glands. Interestingly, the nerve endings of trigeminal nerve are also present in the nose, along with the eyes. So, this compound can also activate the lachrymal glands from your nose, and since the lachrymal duct is joined from eyes to nose, you can also experience runny nose along with tears and irritation in eyes.

References:


Propanethial-S-oxide | University of Bristol
Alliin | Wikipedia
Tear Gas | Wikipedia
Timothy William Lambert, Verona Marie Goodwin, Dennis Stefani, Lisa Strosher, Hydrogen sulfide ($\ce{H_2S}$) and sour gas effects on the eye. A historical perspective, Science of The Total Environment, Volume 367, Issue 1, 15 August 2006, Pages 1-22, ISSN 0048-9697, https://doi.org/10.1016/j.scitotenv.2006.01.034
Encyclopedia of Perception, Volume 1 - 
E. Bruce Goldstein,
SAGE, 2010
The Neurology of Lacrimation – How an Ear Infection Can Cause Dry Eye - 
by Noelle La Croix, DVM, Dip. ACVO