Magnesium is fundamentally important for plants because it is part of the chlorophyll molecule (and chlorophyll is essential for photosynthesis).
Magnesium also acts as a cofactor of several enzymes and it is important the muscle relaxation and for the nervous transmission.