The density of iron is more than the density of water.
Therefore weight of the iron nail is more than the weight of water displaced by it, making the iron nail sink.
But a large ship made up of iron or steel floats becuase the shape of the iron ship is made in such a way that it displaces water more than its own weight. This is done by making the hull of the ship hollow.
The empty space in the hull contains air which makes the average density of the ship less than that of water and hence the ship floats on water.