Earth began, like the other terrestrial planets, as a very hot mass of volcanic material from the newly formed Sun.
The volcanoes released water vapor, which rose, cooled, and formed clouds, which precipitated.
The rain hastened the general cooling of the planet until Earth was cool enough that the water began pooling.
After billions of years, water covered the entire planet.
Another theory is that comets, or meteorites that contained water from the outer regions of the main asteroid belt collided with the Earth and helped fill the earth’s oceans.
Measurements of the ratio of the hydrogen isotopes deuterium and protium point to asteroids as a possible source, since similar percentage impurities in carbon-rich chondrites were found in oceanic water.