The valency of magnesium is 2 because it has two valence electrons in its outermost shell. Magnesium belongs to the second group of the periodic table, which means it has two electrons in its outermost shell or valence shell. In order to achieve a stable configuration, magnesium tends to lose these two valence electrons to form a positively charged ion with a charge of 2+. This makes magnesium a bivalent or divalent element with a valency of 2.