Small magnetic moments arise out of a combination of the charge and spin of subatomic particles. I assume everyone here is aware of what electric charge is, at least enough to get the gist?
Spin is another quantum property, and while it does not at actually represent the particle spinning as such, the combination of charge and spin can be thought of to yield a magnetic moment in sort of a similar way a spinning sphere of charge (from
Ampere's Law). Although it is a
gross oversimplification, it's good enough for a lay discussion.
Spin can arise from both the electrons surrounding an atomic nucleus, and the particles comprising the nucleus itself, though because of the relation that governs the generated moment...
u = g
S q/
2mwhere u is the magnetic moment,
q is the charge, S is the spin
m is the mass, and g is a factor that varies depending on the system
...the moment from the nucleus is far smaller than that of the electrons.
In most atoms, the net electron spins cancel out, due to the manner in which the electron shells are filled (see
here), producing diamagnetic and paramagnetic materials (I won't go into these, as colloquially speaking, these are your 'nonmagnetic' materials).
In a very limited number of materials (Iron, cobalt, nickel, and a few rare-earths), the number of parallel spins is such that the net moment is large enough to reach beyond a single atom.
In these cases, clumps of atoms line up into 'domains'. Normally, these domains are aligned such that they cancel each other out, BUT if you apply a strong enough magnetic field, these domains will line up, and the flaws in the actual crystal structure will hold the domains in place once you take the applied field away. Voila, you have a material with a net magnetic field; a.k.a. a (ferro)magnet.