Loopholes
Earnshaw's theorem has no exceptions for non-moving permanent ferromagnets. However, Earnshaw's theorem does not apply to moving ferromagnets, certain electromagnetic systems, pseudo-levitation and diamagnetic materials. These can thus seem to be exceptions, though in fact they exploit the constraints of the theorem.
Spinning ferromagnets (such as the Levitron) can—while spinning—magnetically levitate using only permanent ferromagnets. Note that since this is spinning, this is not a non-moving ferromagnet.
Switching the polarity of an electromagnet or system of electromagnets can levitate a system by continuous expenditure of energy. Maglev trains are one application.
Pseudo-levitation constrains the movement of the magnets usually using some form of a tether or wall. This works because the theorem shows only that there is some direction in which there will be an instability. Limiting movement in that direction allows for levitation with fewer than the full 3 dimensions available for movement (note that the theorem is proven for 3 dimensions, not 1D or 2D).
Diamagnetic materials are excepted because they exhibit only repulsion against the magnetic field, whereas the theorem requires materials that have both repulsion and attraction. A fun example of this is the famous levitating frog (see diamagnetism).
Read more about this topic: Earnshaw's Theorem