Why is there salt in the ocean?

Because it dissolves easily in water.

Water in the oceans evaporates into the air, leaving solids like salt behind. The water vapor then rises and cools until it falls as rain. If the nearly pure water in the rain falls on land, it dissolves some of the dirt it falls on. Rain that has dissolved carbon dioxide in it is slightly acidic, and the acid helps to dissolve the dirt. Dirt is mostly silica, so about 15% of the dissolved solids in river water turns out to be dissolved silica (silicon dioxide, what glass and quartz is made of).

Many things dissolve more easily than silica. Gypsum for example (calcium sulfate), and chalk (calcium carbonate), each dissolve in slightly acidic water, adding calcium, sulfate, carbonate, and bicarbonate ions to the water. But sodium and chlorine ions are even more soluble. There is just much more of the other ions in dirt than there is salt.

So the solids in river water are mostly bicarbonate ions (from the carbon dioxide in the air), calcium, silica, sulfate, chloride, sodium, and magnesium, in that order.

But when the river water gets to the sea, the organisms in the ocean start to remove ions from the water to build their shells. Diatoms in plankton remove silica. Other plankton and shellfish remove calcium and bicarbonate ions to make shells and  coral reefs.

As the water evaporates and concentrates the ions, the less soluble ones precipitate out of the water and fall to the bottom of the ocean. Calcium carbonate, calcium sulfate, and magnesium sulfate form deposits on the sea floor. But no living organism builds its house out of salt, and very little salt gets locked up in the mud. So ocean water ends up being mostly salt water, with a number of other molecules in it, but in much smaller amounts.