Magnet
Rare earth (lanthanoid) elements have a partially occupied "f" electron shell (which can accommodate up to 14 electrons). The spin of these electrons can be aligned, resulting in very strong magnetic fields, and therefore, these elements are used in compact high-strength magnets where their higher price is not a concern. The most common types of rare-earth magnets are samarium-cobalt and neodymium-iron-boron (NIB) magnets.
Magnetic structure
Most solid materials are non-magnetic, that is, they do not display a magnetic structure. Due to the Pauli exclusion principle, each state is occupied by electrons of opposing spins, so that the charge density is compensated everywhere and the spin degree of freedom is trivial. Still, such materials typically do show a weak magnetic behaviour, e.g. due to Pauli paramagnetism or Langevin or Landau diamagnetism.