The property of ferromagnetism is due to the direct influence of two effects from quantum mechanics: spin and the Pauli exclusion principle.
The spin of an electron has a magnetic dipole moment and creates a magnetic field. (The classical analogue of quantum-mechanical spin is a spinning ball of charge, but the quantum version has distinct differences, such as the fact that it has discrete up/down states that are not described by a vector.) In many materials (specifically those with a filled electron shell), however, the electrons come in pairs of opposite spin, which cancel one another's dipole moments. Only atoms with unpaired electrons (partially filled shells) can experience a net magnetic moment from spin. A ferromagnetic material has many such electrons, and if they are aligned they create a measurable macroscopic field.
The spins/dipoles tend to align in parallel to an external magnetic field, an effect called paramagnetism. (A similar effect due to the orbital motion of the electrons, which effectively forms a microscopic current loop that also has a magnetic dipole moment, is called diamagnetism.) Ferromagnetism involves an additional phenomenon, however: the spins tend to align spontaneously, without any applied field. This is a purely quantum-mechanical effect.
According to classical electromagnetism, two nearby magnetic dipoles will tend to align in opposite directions (which would create an antiferromagnetic material). In a ferromagnet, however, they tend to align in the same direction because of the Pauli principle: two electrons with the same spin cannot lie at the same position, and thus feel an effective additional repulsion that lowers their electrostatic energy. This difference in energy is called the exchange energy and induces nearby electrons to align.
At long distances (after many thousands of ions), the exchange energy advantage is overtaken by the classical tendency of dipoles to anti-align. This is why, in an equilibriated (non-magnetized) ferromagnetic material, the spins in the whole material are not aligned. Rather, they organize into domains that are aligned (magnetized) at short range, but at long range adjacent domains are anti-aligned. The transition between two domains, where the magnetization flips, is called a Bloch wall, and is a gradual transition on the atomic scale (covering a distance of about 300 ions for iron).
Thus, an ordinary piece of iron generally has little or no net magnetic moment. However, if it is placed in a strong enough external magnetic field, the domains will re-orient in parallel with that field, and will remain re-oriented when the field is turned off, thus creating a "permanent" magnet. This magnetization as a function of the external field is described by a hysteresis curve. Although this state of aligned domains is not a minimal-energy configuration, it is extremely stable and has been observed to persist for millions of years in seafloor magnetite aligned by the Earth's magnetic field (whose poles can thereby be seen to flip at long intervals). The net magnetization can be destroyed by heating and then cooling (annealing) the material without an external field, however.
As the temperature increases, thermal oscillation, or entropy, competes with the ferromagnetic tendency for spins to align. When the temperature rises beyond a certain point, called the Curie temperature, there is a second-order phase transition and the system can no longer maintain a spontaneous magnetization, although it still responds paramagnetically to an external field. Below that temperature, there is a spontaneous symmetry breaking and random domains form (in the absence of an external field). The Curie temperature itself is a critical point, where the magnetic susceptibility is theoretically infinite and, although there is no net magnetization, domain-like spin correlations fluctuate at all lengthscales.
The study of ferromagnetic phase transitions, especially via the simplified Ising spin model, had an important impact on the development of statistical physics. There, it was first clearly shown that mean-field theory approaches failed to predict the correct behavior at the critical point (which was found to fall under a universality class that includes many other systems, such as liquid-gas transitions), and had to be replaced by renormalization group theory.
Physical origin
References