A fluid can be at rest - in static equilibrium - only if the net force is zero. On Earth, that requires a balance between a force and gravity. In equilibrium, the force of gravity is the weight of the overlying fluid layers; that’s why water pressure increases with depth, and air pressure decreases with height in the atmosphere. The greater pressure with depth causes buoyancy, an upward pressure force that, for objects less dense than the fluid, results in a net upward force.