In a covalent bond, two electrons are shared between atoms, but their mutual attraction is a result of quantum mechanical principles and the interplay between electrons and atomic nuclei. Here's why they don't repel but instead form a stable bond:
Each electron in the bond is attracted to the positively charged nuclei of both atoms involved in the bond. This dual attraction overcomes the natural repulsion between the two negatively charged electrons.
Electrons are not classical particles but quantum entities that exist as probability clouds or wavefunctions. When two atoms come close enough, the wavefunctions of the electrons overlap, forming a bonding molecular orbital. In this orbital, the electron density is higher between the nuclei, creating a region where the attraction to the nuclei dominates.
The formation of a covalent bond lowers the overall energy of the system. The energy decrease arises because the electrons in the bonding orbital are in a more stable configuration than when they are in separate atomic orbitals. This stabilization outweighs the repulsive force between the electrons.
In a covalent bond, the two electrons have opposite spins (a paired state), which allows them to occupy the same molecular orbital without violating the Pauli exclusion principle. This pairing reduces the repulsion between them compared to two electrons in close proximity with parallel spins.
At the bond length (the distance between the two nuclei in a covalent bond), the attractive forces (electron-nuclei attraction) and repulsive forces (nuclei-nuclei and electron-electron repulsion) reach a stable equilibrium, resulting in a stable bond.
Thus, the covalent bond is a manifestation of the electrons' tendency to occupy a shared, lower-energy state that benefits from the attraction to both nuclei.