The gas reaches your eyes and reacts with the water that keeps them moist. This changes the chemical’s form again, producing, among other things, a mild sulfuric acid, which irritates the eyes. The nerve endings in your eyes are very sensitive and so they pick up on this irritation (this is why our eyes sting when we slice onions). The brain reacts by telling your tear ducts to produce more water, to dilute the irritating acid so the eyes are protected. Your other reaction is probably to rub your eyes, but this will actually make the irritation a lot worse, of course,
Oddly enough, this volatile compound is also responsible for a lot of the great taste in onions, as well as the pleasant aroma when you cook the vegetable.