What holds the atoms in a molecule together?
The atoms in a molecule are usually held together by the sharing or exchange of some of their electrons. When two atoms share a pair of electrons, they form a covalent bond that lowers the overall energy of the atoms and sticks the atoms together. About half of this energy reduction comes from an increase in the negatively charged electron density between the atoms’ positively charged nuclei and about half comes from a quantum mechanical effect—giving the two electrons more room to move gives them longer wavelengths and lowers their kinetic energies.
When two atoms exchange an electron, they form an ionic bond that again lowers the overall energy of the atoms and sticks them together. Although moving the electron from one atom to the other requires some energy, the two atomic ions that are formed by the transfer have opposite charges and attract one another strongly. The reduction in energy that accompanies their attraction can easily exceed the energy needed to transfer the electron so that the two atoms become permanently stuck to one another.