Why do Metals lose Electrons?
As the elements span from left side to right side of the periodic table, the elements become more electronegative and they get more stabilized and attain the characteristic features of noble gas as they move from left to right. If the element is more electronegative, the tendency of it to keep the electrons in it is more. The ionization energy of metals is lower than the ionization energy necessary to take away electron from an atom. Metals tend to give away electrons to form positively charged ions while non metals tend to gain electrons to become negatively charged.
Metals have less number of valence electrons while non metals have more number of them. If there are less valence electrons it is easy to lose them in order to attain stability or reach the electronic configuration of noble gas. If the valence electrons are more in number they can gain electrons to make up the valence shell to attain the electronic configuration of noble gas.
As metals form cations by losing one electron they combine with the halogens easily as the halogens are electronegative and form anions. A strong ionic bond will form between the metals and halogens. Metals have positive charge and the halogens have negative charge to combine with each other forming a strong ionic bond. For example, in the case of sodium the outer shell of this atom will consist of Neon configuration along with 3s1 shell. The outer shell has only one electron which can be given away or lost. The remaining configuration is that of a noble gas. So sodium loses one electron and hence it has the valency as +1.
In the same way lithium loses one electron to attain the electronic configuration of helium. In the same way sodium loses one electron to attain neon gas configuration. The noble gases will have 8 electrons in the outer shell. If there are no electrons left outside the 8 electrons shell then the atom is said to be stable. So, metals lose electrons to attain stability.