Here's why:
* Hydrogen has one electron in its outer shell and tends to lose it to achieve a stable configuration.
* Chlorine has seven electrons in its outer shell and tends to gain one electron to achieve a stable configuration.
When they combine, hydrogen loses its electron to chlorine, forming a positive hydrogen ion (H+) and a negative chloride ion (Cl-). These ions are then attracted to each other due to their opposite charges, forming the ionic compound hydrogen chloride (HCl).