Why is a magnetic material magnetic?
- All electrons have a magnetic moment associated with them, that is just a law of nature that we have to accept..... Even though I detail in basic terms, the math relationship between spin and mangnetic moment, which I have taken from Wikipedia Magnetic Moment , you will still need to accept the notion of magnetic fields as an aspect of nature that currently has no deeper explanation. Although some of the other answers deal far better than I could with explaining electrons in an electric field as a source of magnetism, I wanted to try and answer your question in light of the importance, imo, of magnetic moments and domains in describing magnetism.
The spin magnetic moment is intrinsic for an electron. It is:
$${\displaystyle {\boldsymbol {\mu }}_{\text{s}}=-g_{\text{s}}\mu _{\text{B}}{\frac {\mathbf {S} }{\hbar }}.}$$
Here S is the electron spin angular momentum. The spin g-factor is approximately two: $g_s ≈ 2$. The magnetic moment of an electron is approximately twice what it should be in classical mechanics. The factor of two implies that the electron appears to be twice as effective in producing a magnetic moment as the corresponding classical charged body.
The spin magnetic dipole moment is approximately one $μB$ because $g ≈ 2$ and the electron is a spin one-half particle: $S = ħ/2$.
$${\displaystyle \mu _{\text{S}}\approx 2{\frac {e\hbar }{2m_{\text{e}}}}{\frac {\frac {\hbar }{2}}{\hbar }}=\mu _{\text{B}}.} $$
The z-component of the electron magnetic moment is:
$${\displaystyle ({\boldsymbol {\mu }}_{\text{s}})_{z}=-g_{\text{s}}\mu _{\text{B}}m_{\text{s}}}$$
where $m_s$ is the spin quantum number. Note that $μ$ is a negative constant multiplied by the spin, so the magnetic moment is antiparallel to the spin angular momentum.
The spin g-factor $g_s = 2$ comes from the Dirac equation, a fundamental equation connecting the electron's spin with its electromagnetic properties. Reduction of the Dirac equation for an electron in a magnetic field to its non-relativistic limit yields the Schrödinger equation with a correction term which takes account of the interaction of the electron's intrinsic magnetic moment with the magnetic field giving the correct energy.
For the electron spin, the most accurate value for the spin g-factor has been experimentally determined to have the value
$2.00231930419922 ± (1.5 × 10^{−12}).$
Note that it is only two thousandths larger than the value from Dirac equation. The small correction is known as the anomalous magnetic dipole moment of the electron; it arises from the electron's interaction with virtual photons in quantum electrodynamics. In fact, one famous triumph of the Quantum Electrodynamics theory is the accurate prediction of the electron g-factor. The most accurate value for the electron magnetic moment is
$(−928.476377±0.000023)×10^{−26} J⋅T^{−1}$.
From Magnetic Domains Wikipedia
Moving domain walls in a grain of silicon steel caused by an increasing external magnetic field in the "downward" direction, observed in a Kerr microscope. White areas are domains with magnetization directed up, dark areas are domains with magnetization directed down.
Some materials, such as iron, allow these electrons to clump in organised domains, rather than randomly, which lets iron's molecular structure act to enhance the magnetic effect, so all these magnetic moments are aligned in the same direction.
The domains have to occupy a relatively large volume of the material, depending on their strength. Aluminum is an example of a metal in which the domains exist but are not as organized or as widespread as iron.
Another example of how important the magnetic domains are, is the fact that almost all magnetic materials are solids. In fact melting a solid will normally disrupt its magnetic field, again because domains are disrupted and again iron is special, as the liquid core of the Earth still makes a compass needle move.