An object submerged in a fluid experiences a net upward force due to the pressure in the fluid. This force is known as the buoyant force.
Any object on or near the Earth's surface will experience a force towards the center of the earth.This is due to the gravitational force acting on the object and the direction of this force is typically downwards, on the surface of Earth.
If the net force on an object is zero or in the upward direction, then the object will stay floating.
Hence, the two factors determining whether an object will float or not are buoyant force in the upward direction and gravitational force in the downward direction.