The density of iron is more than the density of water, so the weight of iron is more than weight of water displaced by it and nail sinks. While the shape of an iron ship is made in such a way that it displaces more weight of water than its own weight.