Considering two hydrogen atoms A and B approaching each other having nuclei NA and NB and electrons present in them are represented by eA and eB. When the two atoms are at large distances from each other, there is no interaction between them. As these two atoms approach each other, new attractive and repulsive forces begin to operate.
Attractive forces arise between
(i) nucleus of one atom and its own electron, that is
NA - eA and NB - eB.
(ii) nucleus of one atom and electron of other atom
i.e., NA - eB, NB - eA
Similarly repulsive forces arise between (i) electrons of two atoms like eA - eB.
(ii) nuclei of two atoms NA - NB
Attractive forces tend to bring the two atoms close to each other where as repulsive forces tend to push them apart.

Forces of attraction and repulsion during the formation of H2 molecule.
Experimentally it has been found that the magnitude of new attractive force is more than the new repulsive forces. As a result, two atoms approach each other and potential energy decreases. Ultimately a stage is reached where the net force of attraction balances the force of repulsion and system acquires minimum energy. At this stage two hydrogen atoms are said to be bonded together to form a stable molecule having the bond length of 74 pm.