The question is really two questions. Where does the salt come from, and why does it stay?

Where the salt comes from

Rainwater is naturally slightly acidic — carbon dioxide from the air dissolves into it to form weak carbonic acid, giving unpolluted rain a pH of around 5.6. That mild acid slowly dissolves the rock it flows over, releasing sodium, calcium, magnesium, potassium, chloride, sulphate and bicarbonate into solution.

Rivers carry that dissolved load to the sea. Every river on Earth is delivering minerals to the ocean right now. A second, smaller source is hydrothermal exchange at mid-ocean ridges, where seawater circulates through hot volcanic rock and exchanges ions with it.

How salt water becomes fresh water

Evaporation is a natural distillation. It lifts water molecules and leaves dissolved salts behind — which is both why rain is fresh and why the sea is salty.

How salt water becomes fresh waterSea water evaporates, leaving salts behind in the ocean. Only water molecules enter the atmosphere, so cloud and rain are fresh. Rain falling on land dissolves minerals from rock, and rivers carry those minerals back to the sea, where evaporation removes the water but not the salt — so ocean salinity accumulates.accumulatesdelivers saltSea water~35 g salt per kgEvaporationwater onlyEvaporation: Salt ions cannot enter the vapour phase at ambient temperature; only H₂O molecules leave.Salts stay behindFresh water vapourRainfallessentially pureWeatheringrock dissolvesWeathering: Slightly acidic rain dissolves calcium, magnesium, sodium, bicarbonate and chloride from rock and soil.Rivercarries dissolved minerals
Why the sea is salty
Rivers deliver dissolved minerals continuously; evaporation removes only the water. Over hundreds of millions of years, salt concentrates.
Why rain is fresh
Evaporation is a phase change that only water molecules undergo. Dissolved ions are left behind.
Steady state
Ocean salinity is roughly stable because salts are removed by sediment burial and hydrothermal exchange at about the rate rivers supply them.

Why the salt stays

Evaporation is a phase change that only water molecules undergo. Dissolved ions cannot enter the vapour, so when seawater evaporates, the water leaves and the salt does not. That water returns as rain, runs off into rivers, dissolves a little more rock, and delivers another load of minerals to the sea.

The ocean is the end of the line. Water can leave it; salt largely cannot. Over hundreds of millions of years, that one-way filter concentrates dissolved minerals to the roughly 35 grams per kilogram we measure today.

Why it is not getting saltier

If rivers keep adding salt, ocean salinity ought to keep rising. It does not, on any measurable modern timescale, because salts are also removed: buried in sediments, incorporated into minerals on the seafloor, taken up by organisms, exchanged at hydrothermal vents, and blown ashore as sea spray. Input and output are roughly in balance, and ocean salinity has been broadly stable for a very long time.

What sea salt is actually made of

Major ions in seawater
IonShare of dissolved solidsApproximate concentration (g/kg)
Chloride (Cl⁻)55.0%19.3
Sodium (Na⁺)30.6%10.8
Sulphate (SO₄²⁻)7.7%2.7
Magnesium (Mg²⁺)3.7%1.3
Calcium (Ca²⁺)1.2%0.41
Potassium (K⁺)1.1%0.40
All others0.7%0.25

These proportions are remarkably constant throughout the world ocean — the principle of constant proportions. Total salinity varies between regions; the ratios between the major ions barely do.

Note that sodium and chloride together account for over 85% of dissolved solids, which is why sea salt is essentially sodium chloride with impurities. But river water is not simply dilute seawater — it is typically dominated by calcium and bicarbonate rather than sodium and chloride, because the most soluble ions have long since been flushed to the sea while calcium is continually resupplied by carbonate weathering.

Why some seas are saltier than others

Baltic Sea
2–8PSU
Large river inflow, restricted exchange
Open ocean average
35PSU
Mediterranean
38PSU
Evaporation exceeds inflow
Dead Sea
~340g/l
Terminal lake, extreme evaporation

Salinity is set locally by the balance between evaporation, which concentrates, and precipitation and river inflow, which dilute. The Mediterranean loses more to evaporation than it gains from rivers and rain, so it is saltier than the Atlantic and draws a permanent inflow through the Strait of Gibraltar to make up the deficit. The Baltic receives enormous river inflow into a nearly enclosed basin and is barely brackish. The Dead Sea has no outlet at all, so everything delivered stays.

Sources

More on earth's water