Why does the Earth have radiation belts?

Because it has a magnetic field, and this field acts like a 'bottle' to trap charged particles that are blown towards the Earth by the solar wind or cosmic rays which are passing through the solar system.

Earth's van Allen radiation belts contain electrons and protons with energies of millions of volts. The energy of the particle determines which region of magnetism it will be trapped into. High energy protons are trapped into the innermost belt regions closest to earth while the highest-energy electrons are trapped into the more distant outer belt region.