1) If your surgery will be in part of your gastrointestinal system, having food in your system could complicate the surgery and lead to infection or cause the surgery to be canceled.
 In some cases, a bowel preparation is done, a process that completely empties your digestive tract to prepare for surgery.
2) If you have food or fluid in your stomach during your surgery, you could vomit while under anesthesia. The combination of anesthesia, which paralyzes the body, and intubation makes it possible for you to inhale the vomit into your lungs. This can cause serious complications, such as pneumonia and difficulty breathing, which can compromise your recovery.
Eating before surgery--when you have been told not to--can also lead to nausea and vomiting after surgery. Vomiting after surgery can be extremely painful, as your incision site and your throat may already be sore from the surgery itself.