A magnesium deficiency (hypomagnesemia) occurs when you are not getting enough magnesium—an essential nutrient—in your body. If you have low magnesium levels over a long period of time, this can put you at risk for health conditions and complications. It helps regulate nerve and muscle function, balance blood sugar levels, and assists your body with making proteins, bone, and DNA.