Magnesium is a mineral that helps with healthy bones, muscles, nerves, and blood sugar levels. A lack of magnesium in your diet over time may increase your risk of health issues like diabetes, osteoporosis, stroke, and heart attack. Magnesium can help with: