It seems water might have been present in the solar system even before the birth of the Sun – according to a paper in the September issue of the journal Science (http://phys.org/print330858863.html)
Water locked up as ice that formed in interstellar space is the key ingredient. It is now locked up in meteorites, comets, asteroids and moons etc. Why is there so much of the stuff on Earth?