Mg2+ binds to the same receptor that calcium binds on chief cells. Therefore, when either calcium or magnesium are low, the receptor is not bound and the body senses low calcium -> PTH release.
Now for why extremely low magnesium inhibits PTH release, the theory is that Mg2+ is required for cAMP production and cAMP is necessary for PTH exocytosis. Now, if that was the whole story you would expect to see all kinds of dysregulation in the body with very low magnesium since cAMP is necessary for so many functions. There is probably more to it, but low cAMP with very low magnesium is part of the story.