An interesting twist is that we now know that there is water trapped deep under the Earth's crust in the mantle and 'transition zone' (~500km under the surface) mainly in the form of crystals called ringwoodites (see image opposite, courtesy of University of Alberta) and wadsleytes. They are, of course, rather hot, and water doesn't exist in liquid form 500km under the surface.
However, when these crystals are spewed out to the surface of the earth from volcanoes, scientists can measure their composition using x-ray spectrometry. These crystals contain hydroxide ions (hydrogen and oxygen bound together), or crystal defects that have the potential to liberate a huge amount of water under the right conditions, such as reactions with hydrogen or melting.
How did it get there? Where did it come from? Is Earth unique? What can geophysical measuring techniques teach us about the finer structure of the Earth's interior? Can this water be mined and its contents released, or harvested? Will spaghetti really always break in to three pieces?... Ok that last question was not relevant.
The estimated water content in the 'transition zone' is up to a few times the water content of the oceans... thats a rather large amount!
Two prevalent theories of how water got embedded so deep is: 1) Water that was around during the formation of Earth clung on to dust and coalesced, and made its way in to a self-ordered layered formation (much like liquids of different densities separating), 2) layer formation from regular asteroid impacts containing water...
This doesn't tell us much though. Because if I were to ask you 'how did it get there', you could probably come up with those two options. The difficulty is measuring in situ (i.e. in an actual place where the things happen) and making physical models to describe a whole host of complex interactions including heat gradients, different materials, liquid motion of mantle, dynamic crystallization on large scale, time, gravity, seismic activity, etc. That is no simple matter.
At present, experiments using seismic waves are underway to get a higher resolution picture of what is going on beneath the surface and analyses of crystals spewed out from the 'underworld' also provides insights into the origins of water deep inside the Earth.
Either way, it is fascinating that water, or at least the materials for its liquid form, exists in what was thought to be a most unlikely place.