To float on water, an object must have a density less than that of water. A piece of iron is solid, and has a density greater than that of water. A ship has a thin layer of iron on the outside with an air pocket in the middle, decreasing the overall density of the ship enough to be less than that of water, allowing it to float. A solid piece of iron in a ship shape would not float.
Ship is not a solid block of iron and steel. A ship is a hollow object made of iron and steel which contains a lot of air in it. Air has a very low density. Due to the presence of a lot of air in it, the average density of the ship becomes less than the density of water, therefore, a ship floats in water