Here's why:
* Magnesium (Mg) is an alkaline earth metal in group 2 of the periodic table. It has a +2 charge when it forms an ion (Mg²⁺).
* Bromine (Br) is a halogen in group 17 of the periodic table. It has a -1 charge when it forms an ion (Br⁻).
* To form a neutral compound, two bromide ions (Br⁻) are needed to balance the +2 charge of the magnesium ion (Mg²⁺).
Therefore, the chemical formula is MgBr₂.