Tipping varies extensively among cultures. Though by definition a tip is never legally required, and its amount is at the discretion of the patron, for travellers it can cause some serious dilemmas.
In some circumstances failing to give an adequate tip when one is expected to is a serious faux pas, and may be considered very miserly, a violation of etiquette, or unethical. In some other cultures or situations, giving a tip is not expected and offering one would be considered at best odd and at worst condescending or demeaning. In some cultures it might be seen as a bribe, and in some circumstances (for example tipping government workers), tipping can even be illegal and prosecutable as a serious crime.
In most countries service personnel get paid enough to live on, and they do not have to rely on tips. While intentions are clearly good, (mostly North American) tourists are sometimes not aware of this, (or they know, but they just feel bad not tipping), and they export their generous behavior to other countries where tipping is traditionally not customary, especially to tourist areas. Of course, this is quickly accepted (how would you react if someone gave you extra money) and creates expectations that were not there before. In some places this may also cause the assumption that e.g. Americans will tip generously no matter what and thus get shoddy service, as Americans are assumed to be less inclined to complain or lower their tip than locals, who give lower or no tips.
If you are tipping in a foreign country, ask yourself what that amount means for the one you are giving it to, not how much (or how little) it is for you. In some countries people occasionally get tipped a month's salary. While this definitely is cool for them, it can cause serious trouble. Think a waiter earning more than the chief of police...
Another problem is that, while tipping was originally intended to improve service, some employers use it to underpay workers with the expectation that tips will make up the difference. Good examples for this can be found in Namibia, even at government-owned facilities. There is no guarantee the server even gets to keep the money; some employers may split tip revenue between large groups of workers (as a pretext to pay a lower wage to all of them) or, where legal safeguards are weak, even attempt to pocket a significant percentage for themselves.
Tipping is also an end-around-run to avoid taxes. While there often are technical rules that make income from tips subject to the same taxes as other income, it is hardly if ever reported and thus tips are almost always de facto tax-free — except in the United States, where the Federal Internal Revenue Service assumes that all waitstaff receive at least 15% more than their paycheck income in tips and penalizes them accordingly if they report tip income lower than that. This may or may not be a reason for tips spreading into previously tip-free areas.
In countries where tipping is not customary, attitudes towards the practice can differ. For instance, in Hong Kong or Australia, while tipping is generally not practiced by the locals, it is still welcome (though not expected) by service staff should you decide to do so. On the other hand, in Japan and South Korea, tipping is seen as an insult, and attempting to do so could potentially offend your server.
In countries where tipping is expected (the US for example, where service personnel depend on it), complicated unofficial standards and customs have developed over the exact percentage to tip, and what should and should not be included in this calculation. In other countries and cultures the topic is way more relaxed. It is not easy for the traveller to know what to expect when they go to a foreign country. The idea of this article is to have some basic idea of the customs in other countries before you go there and embarrass yourself.
In some places even locals don't know the correct rules of tipping, so don't worry too much, as many people are willing to cut you as a foreigner quite a lot of slack, if your behavior is perceived to be in good faith.