The water on Earth is brought by comets and asteroids.
4.6 billion years ago, when the solar system was first formed, water molecules must have been in the dust and gravel that produced the planet.
Due to the lack of the atmosphere, the moisture on the surface of the earth quickly evaporated at high temperatures and dissipated into the universe.
In the 700 million years after the formation of the Earth, comets and asteroids continually hit the Earth.
These celestial bodies contain ice, which melts into water when it touches the surface.