That’s one theory. It’s probably the most likely, but I don’t think it has been proven yet.
So here’s the deal. If you look at the outer solar system, there are a bizillion little ice balls out there, some bigger than others. So it’s likely that ice balls and other types of space dust all collapsed together due to gravity and formed the Earth.
But here is where it gets complicated. Fairly early in the formation of the solar system, something roughly the size of mars slammed into the Earth. Needless to say, this wasn’t a happy time for the Earth. The end result of this collision was that whatever crust had been forming on the surface of the Earth was completely obliterated, and a bunch of stuff thrown into orbit around the Earth that eventually formed the moon.
And this gets us to the big question. Did the Earth manage to hang on to all of that water that it had during its formation, or was most of it blasted into space during this collision? If the Earth managed to hang on to its water, then most of it didn’t come from little ice balls like comets slamming into the Earth. But if most of the water got blasted into space, then the water did have to come from little comet ice balls. Otherwise, we wouldn’t have any water.
If you look at ice balls throughout the solar system, there is a fairly common ratio of normal water and “heavy” water (deuterium, a heavy isotope of hydrogen since it has both a proton and a neutron, combined with oxygen). Since heavy water is, well, heavier (duh, way to go Captain Obvious), it doesn’t float off into space quite as easily. If you look at the ratio of heavy water to normal water in the Earth, those ratios imply that while some of the Earth’s water would have had to have come from outside sources (comets, etc), quite a bit of the Earth’s water must have survived the impact that formed the moon.
Yes, but where did the hydrogen and oxygen in those chemicals come from originally? Most likely it came from water, which came from either the formation of the Earth or from comets (or both). That water got split up and the hydrogen and oxygen went on to combine with other elements. So yes, there are quintillions of chemical reactions that can produce water, but the hydrogen and oxygen atoms that are in those chemicals originally came from water.
If you didn’t have all of that water on the Earth to start with, you wouldn’t have all of those chemicals that you can have reactions with to make water vapor.