Iron is a magnetic materials, but it doesn't stay magnetized. When placed near a strong magnetic, the filings get magnetized and line up with the magnetic field lines. Basically each "spike" becomes it's own little magnet oriented with it's north pole facing the south pole of the large magnet. As the large magnet moves, the iron moves as well, trying to keep the same orientation to the magnet.