The density of iron is more than that of water. Iron nail sinks in water because weight of the nail is greater than the weight of water displaced by it. But a ship made up of iron specially designed in such a way that the relative density of ship is always less than that of water.Therefore the weight of water displaced becomes equal to the weight of the ship and hence the ship floats.