Whether an object floats or sinks depends on the size of the upthrust compared with its weight. If the upthrust is less than the weight, the resultant force is downwards and the object sinks. If the upthrust is greater than the weight, the resultant force is upwards and the object rises. If the upthrust is equal to the weight, the forces are balanced and the object floats, staying at the same level.
Density helps decide which case applies. A fully immersed object that is less dense than the fluid displaces fluid that weighs more than the object, so the upthrust is bigger than the weight and the object rises until it floats. An object that is denser than the fluid has a weight bigger than the upthrust, so it sinks.
A steel ship floats even though steel is denser than water. The hull is shaped to displace a very large volume of water, so the upthrust is large and the average density of the whole ship, including the air inside, is less than that of water. A ship therefore floats when it displaces water that weighs the same as the ship.
The density of the fluid matters too. A denser fluid gives a bigger upthrust for the same displaced volume. An object needs to displace less volume to balance its weight, so it floats higher in salt water than in fresh water.