The water in the sea was thought to come from the Earths volcanoes, starting 4 billion years ago, released by degassing from molten rock. More recent work suggests much of the Earths water may come from comets.
Scientific theories behind the origins of sea salt started with Sir Edmond Halley in 1715, who proposed that salt and other minerals were carried into the sea by rivers after rainfall washed it out of the ground. Upon reaching the ocean, these salts concentrated as more salt arrived over time (see Hydrologic cycle). Halley noted that most lakes that do not have ocean outlets (such as the Dead Sea and the Caspian Sea, see endorheic basin), have high salt content. Halley termed this process "continental weathering".
Halleys theory was partly correct. In addition, sodium leached out of the ocean floor when the ocean formed. The presence of salts other dominant ion, chloride, results from outgassing of chloride (as hydrochloric acid) with other gases from Earth's interior via volcanos and hydrothermal vents. The sodium and chloride ions subsequently became the most abundant constituents of sea salt.
Ocean salinity has been stable for billions of years, most likely as a consequence of a chemical/tectonic system which removes as much salt as is deposited; for instance, sodium and chloride sinks include evaporite deposits, pore-water burial, and reactions with seafloor basalts.