This is a subject which occupies many thousand pages of academic and professional books. However, to the layman there are a few general principles that it is useful to know.
1. Water provides a ‘buoyant force’ against objects placed in it.
Essentially it forces them upwards. The amount of buoyant force pushing upwards is equal to the amount of water displaced by the object. The more water you push out of the way, the more force pushes back against you.
2. A ship floats when the amount of water displaced by its hull weighs more than the ship itself.
So if a ship weights five tonnes but its shape means that its hull is making a hole in the water equivelent to about seven tonnes of water, then it will float. There is a ´buoyant force´ of seven tonnes pushing the object up and only a weight of five tonnes pushing it down.
3. If you load more cargo on a ship it will sit lower in the water.
This seems obvious but what is happening is that the ship becomes heavier than the water it is displacing, and so starts to sink. However, in doing so the hull goes deeper into the water, displacing more water, and eventually the water displaced again becomes heavier than the ship, so the ship stabilises at a floating level again.
4. Ships sit higher in cold or salty water.
This is a major reason why internationally trading ships have loadlines on their sides. The lines correspond to different climates, fresh and salt water, so you can keep at a safe level throughout transit. Salty water is heavier than fresh water and cold water is heavier than hot water. So a ship´s hull needs to displace less, i.e. sit lower, to float. For example, if a ship sits high in the water at Felixstowe (cold, seawater), the same ship dropped into an African lake (warm, freshwater), would sit a lot lower in the water.