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 most often de facto tax-free. Exceptions include the United States, where the federal Internal Revenue Service assumes that all waitstaff receive a certain level of tips, penalizing them 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 and not expected, it is still welcome by service staff should you decide to tip. On the other hand, in Japan and South Korea, tipping is seen as an insult, and attempts could 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 – sometimes the rules are so arcane even locals have a hard time keeping it all straight. While in some cases you as a visitor from a foreign country might be given a certain limited degree of leeway, no one — especially in countries where the law allows employers to pay tip-earning workers lower wages — has complete carte blanche to ignore the rules. It therefore behooves overseas tourists to learn at least the basics of tipping custom in the country they are visiting. (Conversely, you as a foreigner can even work the system to your advantage: defying locals' low expectations by tipping appropriately often results in better service than a local would get by giving the same amount!)