A microwave oven heats water because the microwave radiation interacts with the dipole (separated positive and negative charge) of the water molecule. The microwaves turn the water molecules back and forth at approximately the frequency of the microwaves, imparting energy to them. Sometimes you may hear that the microwaves are interacting with a resonant frequency of the water molecule (like a radio gets tuned to a frequency), but that is actually not the case. Anything with a dipole moment will absorb microwave radiation, so microwave ovens will also heat fats and sugars, for example.
A fairly simple explantion of how a microwave oven works is at this website.
As for the second part of the question, there is indeed some danger of sudden boiling of water that has been microwaved. The reason is that it is possible for water to get "superheated." Normally, we think of water boiling when it reaches its boiling temperature. But, boiling doesn't start until there is "nucleation" of bubbles - some irregularity to get the process started. If there is no nucleation, the liquid can be heated above its boiling point (this is called being "superheated"). A similar phenomenon can result in cooling below the freezing point; this state is called "supercooled."
Superheated water can be dangerous. As soon as nucleation occurs (perhaps by putting something in the water or moving the container), all the stored energy which was used to heat the water above its boiling temperature will go into boiling the liquid. This sudden large amount of boiling can produce scalding if you are too close to it.
We have included this second part of the question because it comes up often, especially in the form of a story that has been widely circulated on the Internet. The story tells of an unfortunate person who heated water in a microwave, took it out and looked into the cup, and had the water "blow up" in sudden violent boiling and scald his face horribly. The recipient of the e-mail is urged to forward the warning "to friends and family."
Many stories like this that
get passed around the Internet are hoaxes (especially the ones
that ask to be forwarded to everyone you know).
While this particular e-mail may well be such a hoax, and is probably overly alarmist,
the potential problem it warns about is real.
The possible "Urban Legend" nature of the specific story
that circulates on the Internet is discussed on these Websites:
Please note again (as both of these sites mention) that there is a real danger, because of the possibility of superheating the water.
The U.S. Food and Drug Administration has a page with safety information
about microwave ovens:
FDA microwave oven page
This page updated December 3, 2013