From The Aquarium Wiki
Magnesium (Mg) is a metal and is the eighth most abundant element and constitutes about 2% of the Earth's crust by weight, and it is the third most plentiful element dissolved in seawater. Magnesium ion is essential to all living cells.
It is most often used in PMDD to feed aquatic plants in the form of magnesium sulphate, aka epsom salts.
Green vegetables such as spinach provide magnesium.
Magnesium ion is essential to the basic nucleic acid chemistry of life, and thus is essential to all cells of all known living organisms. Plants have an additional use for magnesium in that chlorophylls are magnesium-centered porphyrins.
It is also found in non-toxic 'Lead Weights' which are actually made of the alloy of magnesium and zinc.