A body floats or sinks due to the difference in their:
densities
Whenever anybody is immersed in a liquid it experiences an upward force. The magnitude of this upward force depends upon the density of the liquid. So, it is due to the difference in density of body and fluid, it floats or sinks.