A star forms when a suitably large cloud of gas collapses due to gravity. The interior of the star heats up, the pressure mounts, and nuclear fusion sets in. A massive star (eight solar masses and up)will fuse all of its hydrogen (the main component of the star at this point) relatively quickly (in about 20 million years compared to 10 billion years for a star like our Sun) and then go on to fuse progressively heavier elements until it starts producing iron, Fe.
Fusion, the process of combining atoms to create energy (E = mc²), works well with atomic masses all the way up to the element iron; that is, you get more energy out than you put in. Starting with iron, however, it requires more energy to fuse atoms together than you get out. The iron accumulates in the core of the star and the core temperature of the star begins to decrease. This decrease in core temperature lowers the pressure within the star so that it can no longer support the material above it, gravity starts to win out, and the star collapses. This collapse causes the core temperature to spike sharply and, after a number of other complicated physical processes (which occur, literally, in seconds), the star rebounds and explodes in a brilliant Type II supernova.