Here's why:
* Barium (Ba) is a metal and readily loses two electrons to achieve a stable electron configuration.
* Chlorine (Cl) is a nonmetal and readily gains one electron to achieve a stable electron configuration.
When barium and chlorine react, barium loses two electrons, forming a positively charged barium ion (Ba²⁺). Each chlorine atom gains one electron, forming a negatively charged chloride ion (Cl⁻).
The strong electrostatic attraction between the positively charged barium ion and the negatively charged chloride ions creates the ionic bond in BaCl₂.