Reduced magnesium (Mg) intake is a frequent cause of deficiency with age together with reduced absorption, renal wasting, and polypharmacotherapy. Chronic Mg deficiency may result in increased oxidative stress and low-grade inflammation, which may be linked to several age-related diseases, including higher predisposition to infectious diseases. Mg might play a role in the immune response being a cofactor for immunoglobulin synthesis and other processes strictly associated with the function of T and B cells. Mg is necessary for the biosynthesis, transport, and activation of vitamin D, another key factor in the pathogenesis of infectious diseases. The regulation of cytosolic free Mg in immune cells involves Mg transport systems, such as the melastatin-like transient receptor potential 7 channel, the solute carrier family, and the magnesium transporter 1 (MAGT1). The functional importance of Mg transport in immunity was unknown until the description of the primary immunodeficiency XMEN (X-linked immunodeficiency with Mg defect, Epstein–Barr virus infection, and neoplasia) due to a genetic deficiency of MAGT1 characterized by chronic Epstein–Barr virus infection. This and other research reporting associations of Mg deficit with viral and bacterial infections indicate a possible role of Mg deficit in the recent coronavirus disease 2019 (COVID-19) and its complications. In this review, we will discuss the importance of Mg for the immune system and for infectious diseases, including the recent pandemic of COVID-19.