When an object is submerged in fluid, the pressure exerts a force in every direction
Pressure increases with depth so the force on the bottom of the object is larger than the force on the top of the object
This causes a resultant force upwards, known as upthrust
Upthrust is equal to the weight of fluid that has been displaced by the object
This means the forces balance and the object floats
If an objects weight is more than the up thrust, the object sinks
An object floating depends on its density, if an object is less dense it displaces an equal volume of fluid to its weight. This means it is completely submerged
A denser object means it is unable to displace enough fluid equal to its weight so it sinks
Atmospheric pressure decreases with height. As altitude increases, pressure decreases as the atmosphere is less dense