If a body is immersed in a fluid, the fluid exerts an upward force on the body called upthrust or buoyancy. You may have noticed while diving into water or going inside water the water exerts upward force on you.

There is a principle known as Archemedes's principle which gives the idea of the upward force exerted by the water. It states that when a body is immersed in a fluid, the fluid exerts an upward force on the body equal to the weight of the fluid displaced by the body.

Figure 1 An imaginary fluid element.
Figure 2 The imaginary fluid element replaced by a solid body of the same shape and size.

Consider a fluid in a vessel as shown in Figure 1 where a fluid element at rest is separated by an imaginary boundary. The fluid element isn't moving so the net force on the element should be zero- the total upward force exerted by the surrounding fluid must balance the weight of the fluid element.

Now replace the fluid element by a solid body of the same shape and size (see Figure 2). Since the solid body has the same shape and size as that of the fluid element, the upward force on the body by the surrounding fluid is the same as that exerted on the fluid element. And hence the upward force on the solid body is equal to the weight of the fluid displaced by the body.

If the weight of the body is greater than the weight of the fluid displaced, the body goes downwards and if the weight of the body is lesser than weight of the fluid displaced, the body goes upwards. Therefore, any body having lower density than the density of fluid floats in the fluid and those bodies having greater density than the density of the fluid sink.