Why magnesium ion is needed for activity of G-proteins?
Ion can change secondary structure of an enzyme. Magnesium ion is coordinated within certain domains (for example, EF-hand motif) and makes them more ordered. Usually it happens via hydrophilic shell of residues embedded into a hydrophobic one (https://www.pnas.org/content/87/15/5648).

You can reverse it by adding a chelator (EDTA, for example) and protein is more disordered which can affect it's activity.