Most men know that certain minerals and nutrients can affect testosterone levels. For example, I cover research that shows that Correcting a Zinc Deficiency Can Raise Testosterone very substantially. Zinc affects literally hundreds of enzymes and can affect the all-important aromatase enzyme that converts testosterone to estradiol. But what about magnesium? Since, it also affects literally hundreds of metabolic pathways in the body, could it somehow produce the same effect?
To answer that question, we have to discuss another key protein in the plasma called SHBG. This binding protein "locks" your testosterone and effective inactivates it from doing anything in your tissues and receptors. Another protein, albumin, also bonds to your precious testosterone, but much more loosely. So, while you do not want low levels of SHBG, you also do not want high levels either, as it tends to lower these two numbers:
1. Free Testosterone: The testosterone not bound to either SHBG or albumin.
2. Bioavaialable Testosterone: The testosterone not bound to SHBG.
Both of these numbers are the indicators of the testosterone ready to do work for you. And, holding all other things equal, as SHBG goes up, your free and bioavailable testosterone will go down. Likewise, as SHBG goes down, your free and bioavailable testosterone go up. I have a whole page dedicated to ways to naturally lower SHBG and thus increase these numbers: Free Testosterone Increasers.
So what does this have to do with magnesium? It turns out that some research shows that magnesium can actually (somewhat weakly) with SHBG. Now it's not a super powerful effect, but it can be significant.  Furthermore, scientists have found that SHBG has metal and mineral binding sites, i.e. magnesium definitely would have a home in this molecule.
Another way to look at this is that a man consuming a healthy, high magnesium diet would have high magnesium levels and some of this magnesium would be binding to his SHBG and increasing his free testosterone. This is the way Mother Nature intended things to be. However, there are many things that can leave us with less-than-desireable magnesium levels and, in this state, too much of our testosterone is taken out of commission. What are some of the things that can negatively impact our magnesium status?
1. Poor Diet. Many men just do not consume enough magnesium rich foods.
2. Soil Depletion. Experts have noted how soils and crops have had steadily declining magnesium levels due to modern, agricultural practices. 
CAUTION: Low SHBG men should not lower their SHBG further. See my page on The Risks and Causes of Low SHBG for more information.
3. Gut Issues. A large percentage of men have intestinal issues. I know on the Peak Testosterone Forum bacterial overgrowth, Crohn's and IBS (Irritable Bowel Disease) crop up fairly often. Other chronic colon conditions that are quite common are diverticulitis, celiac disease, parasites and leaky gut. Put them all together and you've got a large percentage of the population that simply is not digesting their food well and this could end up in lowered levels of magnesium for a variety of reasons.
4. Athletes. There is evidence that heavy exercisers and athletes need ample magnesium. (Conversely, a magnesium deficiency can affect your gym or road performance: one recent study summarized that "both iron deficiency and magnesium deficiency can result in a significant reduction in exercise performance." )
5. Plant Magnesium. I eat almost entirely whole food plant foods. And when you add up the magnesium, it is well over the RDA. However, as a plant food eater, I have to recognize that some of the magnesium will end up bound up in phytate form, albeit this effect is not as powerful as in iron and zinc.  Vegetarians and high plant food consumers need to be diligent in my opinion to truly eat whole foods and NOT rely on all the processed foods that are now available at least here in the U.S. (Plant foods will send your nitric oxide through the roof and give you fantastic gut flora and help you in the bedroom in a 100 different ways. See my book The Peak Erectile Strength Diet for more details.)
Did you know you can inexpensively do your own testing for many hormones? The industry leaders is Discounted Labs..
So how much of an increase can you get by getting rid of low levels of magnesium? Well, I have done a lot of researching and there are very few stories of guys increasing free testosterone with magnesium. If it was a large effect, you would be reading about it everywhere, because college and professional programs would be handing out magnesium tablets like breath mints. So my guess is that, if you are deficient, you might see a 10-20% increase in free testosterone.
But beefing up your dietary and supplemental magnesium can also make you feel better. Several men on our forum have said that magnesium improved their sleep. And magnesium is famed in its ability to decrease anxiety, lower cholesterol and decrease inflammation. The bottom line is that you will likely feel subtely better and, if you feel better and sleep better, your long term baseline testosterone will likely bump up a bit.
WHAT FORM OF MAGNESIUM? If you got into a decent health or supplement store, you'll see literally dozens of choices for magnesium - it can be overwhelming. There is one form that you probably want to avoid and that is magnesium oxide. This is the cheapest form but is poorly absorbed and has a laxative effect. This could make the cure worse than the disease! One governmental fact sheet stated that "mall studies have found that magnesium in the aspartate, citrate, lactate, and chloride forms is absorbed more completely and is more bioavailable than magnesium oxide and magnesium sulfate."  That said, it was magnesium sulfate that was used in the above study. One thing that is popular right now is transdermal magnesium, i.e. "magnesium oil" as well.
1) International Journal of Endocrinology, Volume 2014 (2014), Article ID 525249, "The Interplay between Magnesium and Testosterone in Modulating Physical Function in Men"