It seems like a simple question, and you would think that there would be a simple answer. But apparently this is still up in the air:
The current working theory is that water came from comets that bombarded the earth billions of years ago. See, for example, this NASA blurb that describes the role of comets: "Life on Earth began at the end of a period called the late heavy bombardment, some 3.8 billion years ago. Before this time, the influx of interplanetary debris that formed the Earth was so strong that the proto-Earth was far too hot for life to have formed. Under this heavy bombardment of asteroids and comets, the early Earth's oceans vaporized and the fragile carbon-based molecules, upon which life is based, could not have survived. The earliest known fossils on Earth date from 3.5 billion years ago and there is evidence that biological activity took place even earlier - just at the end of the period of late heavy bombardment."
Several years ago there was a theory that snow comets were still hitting the earth at a rapid rate. This article says, "The small comet theory, developed in 1986 with UI research scientist John Sigwarth from data gathered using the Dynamics Explorer 1 satellite, holds that about 20 snow comets weighing 20 to 40 tons each disintegrate in the Earth's atmosphere every minute. Over the lifetime of our planet, the comets would have accounted for virtually all of the Earth's water. The small comet theory has been controversial almost from the beginning, with some scientists suggesting that images identified as small snow comets actually result from electronic noise on satellite sensors and other researchers asserting that the images represent a real phenomenon. In 1997, Frank revealed a series of photographs taken by Visible Imaging System (VIS) cameras designed by Frank and Sigwarth and carried aboard NASA's Polar spacecraft as further proof of the existence of the small snow comets." There are several problems with this theory, however. One of the biggest is the fact that we've never actually seen one of these 20-ton comets.
The development of a new theory is always interesting because it creates waves in the scientific community and forces people to re-think the data. We'll see how this one pans out.
For more info see: How the earth works