Pre-treat stains as they occur. As soon as you notice a stain on a piece of white clothing, pre-treat the stain. Even if you can't do the laundry immediately, soak the stain in pre-treat solution and make sure to use clean rags to try and remove it pre-wash.
Treat hard water. If you have hard water in your home, it can have a "graying" effect on your whites. To remedy this, add a half cup of vinegar to the washing machine water before you add clothes.
Use the shortest wash cycle possible. Frequent washing can lead to discoloration, so only use long wash cycles if it absolutely necessary.
Alternate bleach with baking soda. Though bleach is good for getting tough stains out of white clothes, it can also produce a yellowing effect if used too often. If you are washing white clothes with light to moderate stains, try using a half-cup of baking soda with your regular laundry detergent instead of bleach.
Wash your washing machine often. Though it sounds a little strange, residue left by doing several loads of laundry back to back can rub off on your whites. The easiest way to clean your washing machine is to run it as if you have a full load of laundry, but don't actually fill it with clothes. Add a cup of bleach and then let it run through the entire cycle.