Forming elements heavier than iron and nickel requires the input of energy. Supernova explosions result when the cores of massive stars have exhausted their fuel supplies and burned everything into iron and nickel.
The star then collapses and explodes. Nuclei with mass heavier than nickel (gold, silver, lead, uranium, etc.) form in the explosions. These elements form over seconds, compared to the lighter ones that took billions of years to form, and are much rarer.
This material is thrown out into space and can end up in later generation stars and planets.
CRAB NEBULA – the remnant of a star about 10 times the mass of our Sun that in 1054 exploded as a supernova