The ocean surface may look turbulent and chaotic but the lower levels can be surprisingly well ordered. structured into distinct layers, each tens of metres deep, each with sharply defined temperature and salinity The density of a region of water depends on its temperature (colder is heavier) and salinity (saltier is heavier).
A warm, less-salty packet of water will rise, while cold, salty water will sink. Dense water gets even denser as it sinks, and rising light water gets lighter. This means even if the water is initially evenly distributed, any perturbation causes it to sort itself into layers.