The electrons of a single, isolated atom occupy atomic orbitals each of which has a discrete energy level. When two or more atoms join together to form a molecule, their atomic orbitals overlap. The Pauli exclusion principle dictates that no two electrons can have the same quantum numbers in a molecule. So if two identical atoms combine to form a diatomic molecule, each atomic orbital splits into two molecular orbitals of different energy, allowing the electrons in the former atomic orbitals to occupy the new orbital structure without any having the same energy.