Why are electrons transferred in an ionic bond?
The modern definition of electronegativity is due to Linus Pauling. It is the power of an atom in a molecule to attract electrons to itself.

When the electronegativity difference between the two atoms  is greater than 2.0, the bond is considered ionic; i.e. there is complete transfer (between the two atoms) of the electrons in the bond.
The electronegativity (according to Pauling scale) of chlorine is 3.0, while the electronegativity  of sodium is 0.9.