In females the ovaries and potentially uterus are removed preventing her coming in to season. Besides reducing the risk of pregnancy and uterine infections, it also stops other animals trying to visit when she is in heat. It also significantly reduces the chances of developing breast cancer, depending on the age of the animal at desexing.
In males the testes are removed, preventing testicular cancer and reducing the risk of prostrate disease. It also reduces aggression, urine marking and the desire to roam. This decreases the risk of injury from fighting or being hit by a car or other potential injuries when outside of your yard.