Magnesium is another mineral you need for optimal muscular function. Magnesium permits nerve chemical messengers to stimulate the muscle cell so that calcium can enter muscle cells, resulting in muscular contraction. This mineral also is necessary to produce ATP or energy during aerobic and anaerobic exercise.