Iron filings can be used to illustrate the direction of a magnetic field, say due to a bar magnet. This works because when exposed to a magnetic field, the filings are themselves temporarily magnetized along their long axis. Now being magnets, they tend to align in the bar magnet's field. But why is each filing magnetized along its longest axis rather than along some other axis? It must be because that is the lowest-energy configuration, but why?
My suggestion is that at the atomic level, each dipole is in a low-energy relationship (or "state") with any dipoles that are end-to-end with it, but at a higher-energy state with any dipoles that are side-by-side with it. Aligning the dipoles the long way results in a greater number of lower-energy states than aligning the short way. For example, consider a tiny iron filing consisting of only 6 dipoles arranged in a 2x3 grid. If the grid is aligned the "long" way, it looks like
^-^ | | ^-^ | | ^-^
^ indicates a dipole oriented up,
| is a low-energy state (north pole of one dipole meets south pole of another), and
- is a high-energy state (north meets north). But if aligned the "short" way (the grid is rotated 90 degrees while keeping the dipoles oriented upward), the 2x3 grid looks like
^-^-^ | | | ^-^-^
In the "long" configuration, there are 3 high-energy states between pairs of neighboring dipoles, and 4 low-energy states. But in the "short" configuration, there are 4 high-energy states and 3 low-energy states. Hence the "long" configuration has the lowest overall energy. You could scale this up to any size grid; the long way is always favored.