Energy changes

Bonds form because the energy of the bonded atoms is lower than the energy of the non-bonded atoms.

For covalent bonds the energy of the bonded atoms is lower due their sharing an electron pair.

This difference in energy between bonded and non-bonded atoms is a difference in potential energy (energy of position). 

The potential energy of a system decreases when two objects that have an attraction for one another are brought closer together.  Positively-charged objects are naturally attracted to negatively- charged objects.
 
The energy of the bonded atoms is lower than that of the isolated hydrogen atoms because the negatively-charged electrons in the electron pair bond are each close to two positively-charged nuclei. 

H•  + •H  H H (or H—H)
 
The diagram shows that when the atoms approach one another, the energy of the system decreases to a minimum when the electron pair bond is formed.

If the atoms are brought closer, the energy of the system increases due to repulsive forces between the positively charged center of two atoms.