Water is Hydrogen + Oxygen, two of the most abundant things on Earth.
Much of the Earths crust is made up of Oxygen, bonded to other things like Iron to make minerals.
Since a lot of Oxygen existed on the primeval Earth, and Hydrogen is the most abundant thing in the Universe, having water was inevitable.
So where did it come from? Either the Earth was formed from material that contained a lot of Oxygen and Water, or the early Earth was bombarded with Comets and Asteroids that contained Oxygen and Water.
Latest Answers