L-S coupling
When we try to combine quantum mechanics with relativity, in the case of
Fermions (as in the Dirac
equation), conservation of angular momentum requires the introduction of
an extra angular momentum which has no analog in classical mechanics. This
is called the spin. In the case of the electron, this angular
momentum (magnitude) is expressible through the quantum number 1/2. Since
the electron is charged, there is also a magnetic moment associated with
the spin.
Note: Do not try to imagine the spin as a kind of spinning motion
of the particle. This is a purely quantum-mechanical phenomenon and any
classical analogy is bound to be wrong.
From the point of view of the electron, the nucleus is a positive charge
going around it (due to the orbital motion of the electron). This creates
a current loop which produces a magnetic field at the site of the electron.
The magnetic moment of the electron due to the spin interacts with this
magnetic field to cause small changes in energy.