To some extent that is random. It is like rain drop formation: a drop gets a certain size and starts to grow by "eating" small drops around it. A filing attracts the nearest particle, and their attraction grows stronger; however, at a certain distance that attraction is still very small and there, a second particle can become the nucleus.
It's a chaotic (nonlinear) system that finds an equilibrium when all the "unconnected" particles have been connected to a larger cluster.
Well this is a good example of a system seeking to minimise its energy.
Without the filings the magnetic lines are 'evenly' distributed in space with no gaps.
Even is not exactly right since obviously the field strength diminishes with distance from the pole to pole centreline, but I think you know what I mean.
Just as with a transformer or motor core, the field lines (want to) congregate in a ferrous material ie they are drawn into it, leaving few lines in the free space not occupied by the ferrous material.
But these paths have to be continuous through the core.
Cores are not free to move, fine particles are.
So the system can rearrange itself when fine particles are introduced.
And yes, indeed there are few lines in the spaces and a concentration of lines in the chains of ferrous particles.
If you were to plot some lines at right angles to the chains you would find repulsive (N-N and S-S) forces in action, which is why you get spread out lines rather than a block in the middle.