Archimedes’s principle states that a body immersed in water displaces a volume of water, and if this displaced volume of water weighs more than the weight of the body immersed, the body will float. If the displaced volume of water weighs less than the weight of the body, the body will sink.
An object will float if it weighs less than the amount of water it displaces. So here the weight of the ship is less than that the amount of water it displaces. Hence it floats on water.