Your body has to move calcium ions in and out of (striated) muscles to trigger contractions. This is done through "calcium channels". Mg2+ is an antagonist to the activation of calcium channels.
You need enough calcium to achieve a strong reliable contraction, and enough magnesium to keep the channels "closed" when they should be closed (among very many other physiological uses).
In short, you need a balance of calcium and magnesium for reliable muscle function. A gross excess or lack of either is bad.