I have a long history with magnesium, which I won’t completely go into, but when I am deficient in magnesium I develop restless legs and heart palpitations. If I get really deficient, I also get some anxiety. I need to supplement about 500 mg a day. If I get lazy and stop supplementing, the symptoms return.
I read a book years ago called The Magnesium Miracle by Carolyn Dean. It was all about how important magnesium is to the body and all the problems that can develop due to deficiency. You may want to give it a read. I like her first edition better. In the second edition she really pushes her ReMag supplement. That gets a little annoying, but the information is still sound.