Hydrogen is the most abundant element in the universe. The second most abundant, helium, is noble and doesn’t form molecules, but escapes into space instead. The third most abundant is oxygen, which combines with hydrogen to make water. Water is the most abundant molecule in the universe, which is why we have so much. There are whole moons in the outer solar system made of it.
So maybe the question to be asking is not "Why do we have oceans?", but "Why don't we have more oceans?" Possibly even to the point of covering the entire earth.