According to Lewis's theory, the hydrogen molecule is formed by pairing the pair of electrons contributed by each hydrogen atom.

In the valence bond theory, the bond is produced by overlapping of the 1s orbitals of each hydrogen atom. This overlap means that both orbitals share the same region of space.

When the two atoms get closer, the potential energy of the system decreases until it reaches a minimum value, which corresponds to the maximum overlap of the 1s orbitals. At this point the bond distance and its energy are obtained.
If the hydrogen atoms continue to get closer, the energy of the molecule begins to rise due to the repulsion between the nuclei.