The atoms that embark on the journey of bond formation are likely to have an electron imbalance. They are less stable and become highly reactive. These atoms seek 8 electrons in their outermost shell to lower their reactivity and achieve stability.
The number 8 as the stable electronic configuration the atoms pursue was formulated by Gilbert N. Lewis in his ‘octet rule.’ According to him, all noble gases (He, Ne, Ar, Kr, Xe, Rn) are stable, and their octet configuration guarantees stability. The exception is Helium which prefers the duplet state.
The inertness of the noble gas atoms under normal conditions is attributed to their complete shell, and therefore, they are unreactive with another atom, preferring sole existence. In comparison, other elements try to attain stability by losing, gaining, or sharing the electrons to reach the electronic configuration of their nearest noble gases.
For example, the electronic configuration of Sodium is 11. It must lose one electron to reach the nearest noble gas configuration of Neon or gain seven electrons to reach the configuration of Argon. Sodium prefers to lose one electron rather than gain seven electrons. However, a Chlorine atom with 7 outer electrons in the same row is devoid of one electron from the stable configuration. Instead of losing all 7 electrons to reach the Neon configuration, it prefers to gain one and attain the electronic configuration of Argon. Losing or gaining many electrons is not an energetically feasible process for an atom.
The other atoms that don’t have too much to lose or gain prefer a middle path -sharing.
An atom’s preference to lose, gain or share electrons determines the type of bond it will form, whether covalent or ionic. Their electronegativity (in addition to ionization and electron gain enthalpy) values control the bonding preference.
Only those elements with an electronegativity difference of 1.7 and higher chose to lose or gain electrons to form ionic bonds.
Most elements below the electronegativity difference value of 1.7 prefer to share the electrons to form molecules with a covalent bond. These elements are usually nonmetals on the periodic table's right side.
For example, a nonmetal carbon forms covalent bonds with other nonmetals, Nitrogen, Oxygen, Hydrogen, and Halogens because these combinations have electronegativity values below 1.7. Therefore, we see many organic carbon compounds with C-C, C-N, C-H, C-O, and C-X covalent linkages.
The sharing of the electrons in a covalent bond mutually benefits the atoms involved. The shared electrons are part of both atoms' nuclei, and they simultaneously fulfill their octet/duplet configuration.
By bonding, the atoms lose their reactivity; the final molecule is lower in energy and more stable than its parents.
For example, an individual H atom with a single electron is high in energy. The atom wants to gain one electron to fulfill its duplet state. When two H atoms share one electron each, both attain the stable duplet configuration of Helium (He) and form one hydrogen (H2) molecule. Other combinations are H atom (less by one) with Cl atom (less by one) to form HCl molecule, C atom (less by four) and four H atoms (each less by one) to form CH4, N atom (less by three) and three H atoms (each less by one) to form NH3.
Nitrogen only required three more electrons to complete its octet, forming three bonds with Hydrogen. The remaining unpaired electron on Nitrogen is called the lone pair. Oxygen requires only two more electrons to form two bonds with Hydrogen to meet its octet requirement. The unused electrons are the Oxygen atom’s lone pair. In the above HCl example, Chlorine has three lone pairs. So, the electrons in the molecule are divided into two parts- bond pairs (electrons involved in bonding) and lone pairs (electrons uninvolved in bonding).
Related Reading: Electronegativity