Though you are unlikely to cross paths with royalty the next time you are buying groceries or going to a nightclub, it is a good idea to be prepared even for rare occasions such as this. Countries are generally protective of their dignitaries, and therefore it is important to observe the local customs and protocol when meeting heads of state such as the Queen of England.
Bowing to another country's royalty is not required of foreign travellers. An American in England, for example, would not necessarily have to bow to the Queen, as he is not one of her subjects. Travelling dignitaries may choose to bow as a show of respect, though some presidents have taken criticism for doing so, as Barack Obama did when he bowed to Japanese Emperor Akihito in 2009.
Generally speaking, royalty should be treated like, well, royalty. This means that you should never touch royalty without first being touched, or being given permission to do so. For example, if the Queen of England offers you her hand, you may give it a brief and gentle grasp. If she is particularly fond of you, as she was fond of First Lady Michelle Obama when the two met in 2009, she may even offer a hug---but those occasions are few and far between.
It is important to address royalty with the proper respect. For instance, you would first refer to the Queen as "Your Majesty," and then "Ma'am." Other members of the British royal family are referred to as "Your Royal Highness," and subsequently either "Sir" or "Ma'am."
Some countries have specific etiquette for greeting dignitaries. In Malaysia, for example, those greeting the king should put their hands together and raise them to their foreheads. If you know in advance that you will be meeting royalty, it is important to research the country's specific customs.
Members of royalty may be revered, but they can also be understanding. Depending on the culture, members of royalty likely understand that not everyone is well versed in the proper etiquette---if you breach protocol, a simple apology will probably suffice. Generally, you should behave for royalty as you would anyone else whom you wish to impress: respectfully and politely. Do not turn your back to royalty or talk about hot-button issues like gossip or private matters, and do not chew gum or make jokes at their expense.