4.5 billion years ago the proto earth was still a seething mass of dust and gas. There probably was a lot of water mixed in because hydrogen is the most common element in space and oxygen is the third most common. (Helium is second). Then, a mere 30 million years later disaster struck big time. A proto-planet the size of Mars rammed into earth, smashing debris into space that later coalesced to form our moon. Any water that had existed near the surface would have been blown away in the blast. So was the atmosphere.

We know that water exists in surprising places. In 2015 the Cassini spacecraft spotted water vapour and frozen particles erupting from the south pole of Enceladus[1], one of Saturn's many moons.
One theory has it that planet earth's oceans came from comets or asteroids that rocketed down after the moon coalesced. Early on, there were an awful lot of icy bodies banging around the solar system. The gravity of the large gas giants that were evolving had a tendency to fling smaller bodies such as asteroids and meteorites from outer, icy orbits onto the rocky planets that were forming closer to the sun. Think of a god bowling in 4d, erratically tossing rocks, gasses and ice at earth and other proto-planets. Sometimes strikes were made. Comets or asteroids? The obvious choice would seem to be comets, with their long icy tails that show up easily even to the naked eye. But that theory ran into trouble when it was discovered in the 1980's and 1990's that the deuterium/hydrogen ratio on observed comets did not match that of earth's oceans. Deuterium is a heavier isotope of hydrogen, and if the oceans were made of comet material the ratios should match.
That leaves asteroids. Or does it? Many asteroids, especially those far out in the solar system, are made of hydrated rocks. Ceres is the largest remaining asteroid in our solar system, at 900 kilometers wide, and probably half of its mass is water. If just five Ceres-size asteroids once collided with earth, all the water in the earth's oceans would be accounted for.
Unfortunately there is a noble argument against this theory. Xenon and argon are called "noble" gases because they are essentially inert. The proportion of these gases in asteroids is different from that found in oceans on earth. They should be similar. A counter argument to the falling-from-the-skies theory has it that the water was there far below the surface right from the start, in the form of separate hydrogen and oxygen molecules and also as hydrated rocks. Over eons this water was pushed to the surface and formed the oceans. Volcanoes puff out water and CO2 even today. Oceans from rocks. Who knew? It's a mystery.

An amazing thing -- the oceans that cover roughly 70% of the surface of planet earth seem vast, but compared to the volume of the earth they are extremely tiny. Surprisingly, the earth, including all of its oceans, is 100 times dryer than an old bone. Think of a giant ball with a very thin, increasingly fragile, film of water covering its surface. What a film, though. Life on earth began in the oceans with single-celled prokaryotic cells about 3.8 billion years ago. Half of the oxygen that we breathe came from the oceans. The ocean supports a vast variety of life ranging from tiny marine viruses to giant blue whales, the largest creatures that have ever existed on our planet. Millions of people draw their livelihood from the sea and over a billion depend on the oceans as their primary source of protein.
[1] Enceladus is the sixth-largest moon of Saturn. It is about 500 kilometers (310 mi) in diameter, about a tenth of that of Saturn's largest moon, Titan. Enceladus is mostly covered by fresh, clean ice, making it one of the most reflective bodies of the Solar System.