I am going to explicitly plagiarise! From Wikipedia https://en.wikipedia.org/wiki/Iron_filings. I'm leaving it pretty much as-is because it's written better than I would put it.
"Iron filings are very small pieces of iron that look like a light powder. Since iron is a ferromagnetic material, a magnetic field induces each particle to become a tiny bar magnet. The south pole of each particle then attracts the north poles of its neighbors, and this process is repeated over a wide area creates chains of filings parallel to the direction of the magnetic field."
If I were to add to this, to think more about the gaps, I would say it might help to step back and think about adding one filing at a time - like the double slit experiment (cos that always makes things really easy to understand, right! ;).
Wherever we put the first piece, it will line up with the field (because it becomes a bar magnet itself).
But if we've put this filing very near one end of the magnet, the magnetic force is strong - if it is strong enough to overcome friction, the filing will slide along and touch the magnet. Further pieces added to that region will do likewise. But, after lots of them have been added, there is no more room for choice. The layer is one-dimensional, so the new additions cannot get to the main magnet; they have to be satisfied with abutting the existing filings. Eventually, the region ends up entirely full - the dense black regions at either end.
When we add a filing a further away from the ends of the magnet, they still line up with the magnetic field because the magnetic force is strong enough to overcome the local friction involved in spinning. But it is not strong enough though to cause the filing to physically slide over to the magnet. If we add another filing very close to that one, it will feel the first filing's new magnetic force and move to stick to it - N-S-N-S. If we add a third one a little further away, it will be too far to feel the 2 filings and will rotate, but remain where it is. Once you end up with some strings of NSNSNSNSNS's here and NSNSNSN's there, they will reinforce more and more. Further new filings will 'want' to join one of these chains, rather than sit in 'empty' space. So the chains want to grow ever thicker but the spaces want to remain empty.
But at some point, we stop adding filings. And maybe /this/ is the key explanation, then! What if we don't stop but we carry on adding more filings? The next filing will plop into a gap but move and stick to a chain. The one after that will do likewise. And the next, and the next. Gradually, all the space will be used up - and the entire area around the magnet will end up as solidly packed as the area near the ends. It will just be one big, black mass of lined-up filings.
That would not make a very good demonstration of the magnetic field lines, so if my reasoning is right, you only want to have a limited number of filings when making these demonstrations - and similarly, Wooly Willy! ( https://en.wikipedia.org/wiki/Wooly_Willy)