What is irons function in stars?
Iron is the cause of the death of large stars.
Larger stars heavier than about 8 solar masses start by fusing hydrogen into helium. As the hydrogen supply runs short they start fusing helium and progress to fusing heavier elements.
The fusion reactions provide an outward pressure which resists gravity trying to collapse the star. In main sequence stars the outward pressure and gravity are in balance and the star is in hydrostatic equilibrium.
All of the fusion process creating elements up to iron produce energy. Fusion of iron and heavier elements require additional energy.
Once a star's core contains a sufficient amount of iron, fusion process slow down and gravitational collapse takes place. A predominantly iron core will collapse and cause a supernova explosion leaving behind a neutron star or a black hole.