Some medications are difficult to digest; taking them with food serves to protect the stomach. In addition, other medications are better absorbed by the body when food is present. You need to be especially careful, however, since some foods must be avoided when taking certain medications in order to avoid affecting the way they are absorbed by the body.
Other medications must be taken on an empty stomach (at least 1 hour before or 2 hours after a meal), since that is how the active ingredient is best absorbed by the body, ensuring an optimal treatment.
Every case is unique, however. If you have any questions about your medications, ask your pharmacist.