The push of displaced water
Anything placed in water pushes water aside, and the water pushes back. Archimedes' principle states the rule exactly: the upward force, called buoyancy, equals the weight of the water displaced. A floating object settles at the depth where the displaced water weighs exactly as much as the object itself — then the forces balance and it stays there.
If the object is heavier than the water it can possibly displace, it sinks. That is what density decides: an object denser than water, like a solid steel bolt, can never displace its own weight before it is fully underwater, so down it goes.
Steel that floats — because of air
A steel ship seems to break the rule, since steel is about eight times denser than water. The trick is the hull's shape: the ship is mostly hollow, a steel shell wrapped around a vast volume of air. Averaged over the whole ship — steel, air, cargo and all — its density is less than water's.
Try it in a sink: a ball of modelling clay sinks, but the same clay shaped into a boat floats, because the boat shape displaces far more water before it goes under. Ship designers live by this: widen or deepen the hull and the ship can carry more before it sits too low.
Floating high, floating low
Only about a tenth of an iceberg shows above the surface, because ice is only slightly less dense than seawater — roughly ninety percent of its bulk must stay submerged to displace its weight in water. Ships carry painted load lines on their hulls for the same reason: they float higher in dense salty water and lower in fresh.
Submarines turn buoyancy into a steering wheel. By flooding tanks with water they make themselves heavier and sink; by blowing the water out with compressed air they become lighter and rise. Hovering motionless mid-water means matching the displaced water's weight exactly — neutral buoyancy.

