Why do atoms join to form bonds?
To stabilize themselves and fill their valence shells.
With the exception of the noble gases, the other elements do not have completely filled valence shells (the outermost energy shell). So, in order to fill these energy shells (valence shells), atoms form various bonds to stabilize themselves.
There are 8 valence electrons in a full valence shell with the exception of Hydrogen and Helium, with 2.