Magnesium deficiency contributes to osteoporosis by acting on the process of crystal formation and promoting low grade inflammation.