The usual disclaimer: None of this applies if you have food allergies. And this is not meant as medical advice: I am not a medical professional, and all opinions here are a product of my own experience and research.
I've only had food poisoning once, and it was from a sleek, tourist-oriented restaurant in Singapore's Little India. The following night, I went to a 24-hour Indian place where was served out of a buffet table by a surly, mustachioed fellow in an undershirt -- and I was fine.
There's a lot of unsubstantiated fear about food poisoning out there when traveling abroad. Ask Americans to name one place that has an unsafe food supply, for instance, and they'll probably say China. But, ironically, a recent New Yorker article suggested that many mainland Chinese are just as afraid to eat the local cuisine when traveling in Europe. The fact of the matter is that the inhabitants of developing nations are not supermen, and are vulnerable to much the same dangers that visitors are. So the first rule of avoiding food poisoning is to act like a local.
Beyond that, you need to have a threat model that allows you to judge how much risk you're taking. I see three categories of food- and water-borne threats out there.
The immediate threat: Microbial Infection
This is the classic danger -- the Delhi Belly, Montezuma's Revenge, traveler's diarrhea. You eat food that had either spoiled, or was undercooked, or not washed properly, or you drank water from an unsanitized water supply. Now, you have to contend with a day or two of brutal sickness.
If you're eating at places that are popular with the locals, you're already minimizing your chances of getting sick. But you have to accept that you will probably have some sort of problem along the way: traveler's diarrhea is the most common illness among tourists. And while there are fairly rare cases that can threaten your long-term health -- you should always seek medical attention if symptoms don't begin to improve within a couple of days, or symptoms are extremely severe (blood, etc.) -- most of the time you'll come out unscathed. The most important thing to do is to stay hydrated: rehydration salts should be on the top of your medical kit list (see below). There's also vaccinations you should get that can reduce your chances of severe illness (see below).
There's a reason that many traditional cuisines don't feature uncooked vegetables; the salad is an invention of the modern world. Without clean water to wash food, the surest way to make food safe is to cook it thoroughly. Always keep that in mind. Many places, I would find the local Subway sandwich shop (and they're everywhere that the middle class is, these days) if I wanted fresh green vegetables.
As for local tap water in the developing world, you probably shouldn't drink it; in most places, the local people don't, either. (If you're wondering, many towns have water tanker trucks that come through once or twice a week with drinking-quality water). But that didn't stop me from brushing my teeth with tap water in Bali, China, or Thailand, and it didn't stop me from boiling tap water to cook pasta, either.
Toxic Chemicals: When Boiling It isn't Enough
The other reason that water and food supplies are considered unsafe is that they're contaminated with toxins, usually from human activity. This is a problem everywhere: in Maryland's Chesapeake Bay, for instance, the local government recommends that you eat no more than three servings of wild rockfish a month to avoid long-term damage from PCBs.
If you're following the common-sense rules described above, it's highly unlikely that anything you eat or drink is going to be toxic enough to hurt you in the short term. And it's not fair to think that toxins are more likely just because food is of a foreign source: much of America's seafood comes from Southeast Asia, after all. But it is worth keeping in mind that eating pollutant reservoirs like seafood for months on end, or eating pasta every night that's been cooked in tap water that's full of industrial contaminants, might harm you in the long run. Just keep your diet balanced, and remember that there's very few things that will hurt you in the right quantity.
Just make sure that your food, especially pork, is cooked all the way through. You don't want to end up like the city of Phoenix's former chief financial officer Kevin Keogh, who was infected with a pork-borne parasite that eventually drove him insane. He eventually died when he became convinced that car-surfing his Mercedes was a good idea.
Author's note, 2018: Apparently the parasite explanation was ruled out some months later after autopsy.
So do make sure your food is cooked through to the core.
Vaccination against Cholera and Food Poisoning
There's two food poisoning-related travel immunizations that you should consider before traveling. The first is for typhoid fever, a water-borne illness that is thankfully gone from the developed world. The second is called Dukoral, and is not currently licensed for distribution in the US. You can, however, get it in Canada, the UK, and many other countries. It provides partial protection against cholera (another water-borne illness) and traveler's diarrhea.
Both will significantly lower your odds of severe food poisioning. I never took Dukoral, however, and I was fine.
Always Carry Rehydration Salts
Finally, I want to repeat something from my earlier entry on travel health. Bring rehydration salts with you, and be familiar with how to use them. They can make a case of food poisoning or dehydration much more bearable and short lived: they might even save your life.