The law of floatation states that when a body is wholly or partially immersed in a liquid, it floats if the weight of the liquid displaced is equal to the weight of the body. If the weight of the liquid displaced is more than the weight of the body, it sinks.
The principle of floatation was first stated by the Ancient Greek scientist Archimedes. He stated that all objects placed in a liquid experience an upward force which allows the body to float if it displaces water with weight equal to the weight of the body. This upward force is called the buoyant force and the law is called the law of buoyancy.
This is why a ship weighing several tons floats while a needle sinks. A ship is made of iron and steel but it has a lot of space filled with air. This causes the ship to displace water with a weight equal to the weight of the ship. The needle displaces more water than its weight and hence it sinks.
Floatation has a lot to do with density. If an object has density less than the density of water, it floats. Cork floats on water because the density of wood is less than the density of water. An iron nail sinks in water because the density of iron is more than the density of water.