That is a great question, and the answer is that its "fact", although you donít get a very strong magnet this way. To see how this works it is important to understand that a steel bar (iron) is made up of billions and billions of individual atoms that each have the properties of a microscopic magnet. The atoms in iron naturally tend to get together in tiny little groups called domains, and within each domain the atoms tend to point in the same direction, which makes the domain behave like a tiny little bar magnet just like the kind you have probably played with at school. The needle of a compass is also a bar magnet, and we know what this does: it points north because it likes to line itself up with the magnetic field of the earth.
When you make a piece of iron, all of the tiny domain-magnets inside tend to get stuck pointing in different directions, which means that they more or less cancel each-other out, so whole piece of iron does not behave much like a magnet at all.
Just like the needle in a compass the little domain-magnets inside the iron would like to align themselves with the earths magnetic field, but since they are stuck they canít. When you hit the bar of iron you can think of this as jiggling some of the domains loose for an instant, letting them line themselves up with the earths field. If you keep hitting it then eventually enough domains will be lined up that the bar itself starts to behave like a very weak magnet.
This is what happens to train tracks rails: The train rolling on them jiggles them enough that eventually the rails become slightly magnetic.
(republished on 07/13/06)