The short answer is that the electrons in the atoms orient their orbitals perpendicular to the direction of the magnetic field.
Classically, the magnetic field is caused by moving electric charges. On the other hand, moving electric charges are effected by the magnetic field.
If you imagine an atom as a little planetary system (which it's not - that's the old Bohr model) then the magnetic field makes all the orbits of the planets perpendicular to it. So all the atoms are pointing in the same direction. Which produces an attractive force on the thing that created the magnetic field in the first place. You need a couple of vector cross products to explain this adequately. Hard to do in this editor!
That's the short answer. For the long answer, get a book on quantum electrodynamics. That will provide fun and entertainment for years!
Take a look at the second section Sources of Magnetism, in http://en.wikipedia.org/wiki/Magnetism
They explain it better than I did, but I think I am consistent with them. And it's on Wikipedia, so it must be right!?