But how come you have magnesium deficiency in the first place, what are you not eating? People who need magnesium supplements still absorb magnesium, so the problem isn't absorption must be consumption.
Fresh fruit and veg, nuts, and other fresh things. Thing is, modern farming and distribution practices have negatively affected the magnesium content. Drinking water also used to naturally contain more minerals but in many places is removed to cause less issues with plumbing and because “hard water” also makes it harder for soap to lather.
Absorption also depends on vitamin D, so if you’re low in D, you won’t absorb as much magnesium.
I have also read that magnesium is required by the body to make GABA and melatonin; supplements other commenters are mentioning.