Nature runs a continuous water cycle where ocean water evaporates, forms clouds, falls as rain, and returns to the sea through rivers. Water molecules mostly make up the vapor that rises from the ocean during this cycle. The salt simply stays behind in the sea. The vapor cools down into clouds and falls as rain, which acts as freshwater with very low salt.
Rainwater flows over the ground and dissolves minerals from rocks and soil. Rivers then carry these minerals back to the oceans. Oceans have accumulated massive amounts of salt because this water cycle has continued for millions of years. The salt level in the ocean does not stay exactly the same everywhere, though. Rainfall, river water inflow, and evaporation rates change the salinity in different regions.