Anything floats or sinks based on whether the buoyant force is more or less than the weight.
If the buoyant force, which points in the upward direction, is more, than the object will float and not sink.
If the weight , which points in the downward direction is more than the object will sink.
a piece of iron, because it has more density than water, its weight will be more than the buoyant force and it will sink.But in the case of the ship, because there are so many open spaces in the ship, which are filled with air, it does not sink. The overall density of the ship is less than the density of the water.
same thing happen to the fruits, in orange, you put it in glass of water it will float in water but when you remove the air bubbles by peeling the orange, the orange is unable to float and thus sinks to the bottom of the glass.
same thing in life jacket when air feel in jacket it will flots.