Onions, like other plants, are made of cells. The cells are divided into two sections separated by a membrane. One side of the membrane contains an enzyme which helps chemical processes occur in your body. The other side of the membrane contains molecules that contain sulfur. When you cut an onion, the contents on each side of the membrane mix and cause a chemical reaction. This reaction produces molecules such as ethylsufine which make your eyes water.
To prevent crying when you cut an onion, cut it under a running tap of cold water. The sulfur compounds dissolve in water and are rinsed down the sink before they reach your eyes. You can also put the onion in the freezer for ten minutes before you cut it. Cold temperatures slow down the reaction between the enzyme and the sulfur compounds so fewer of the burning molecules will reach your eyes.