This one is pretty easy!
Eat more foods that are high in magnesium: Spinach, almonds, cashews, cocoa, and pumpkin seeds.
If you are still not hitting the daily recommendation, consider adding it in supplemental form.
Magnesium orotate (an amino acid chelate), lactate, or citrate are all highly bioavailable.
Each of these will have slightly different effects based on your individual biochemistry. In other words, I haven't found a one-size-fits-all source of magnesium that everyone loves. Experiment with the different forms and choose the one that feels the best for you.