Over billions of years soluble compounds have been dissolved out of eroded rocks by rainwater and transported to the oceans. The concentration of compounds in the oceans increases over time because the process of evaporation of sea water removes only pure water leaving the soluble compounds behind.
Since these compounds are in an aqueous solution they exist as cations (eg. sodium, potassium, calcium, magnesium) and anions (eg. chloride, bromide, iodide) It is a simple process to produce elemental iodine (or bromine) from sea water, bubble chlorine gas through it.