I heard that special relativity could be used to explain the working of electromagnet, but couldn't dig anything out of it. Can somebody give some explanation of the above?
Beware, the explanations that employ length-contraction are wrong. They are "lies to children". The minutephysics explanation was absolute junk I'm afraid. The moving cat ion is in the same situation as the observer, but with ions moving instead of electrons moving. And a positive particle isn't repelled from the wire, it moves around the concentric magnetic field lines in a helical fashion. I say all this as a "relativity guy". I you take a look at Hermann Minkowski's Space and Time you can find the real reason:
"In the description of the field caused by the electron itself, then it will appear that the division of the field into electric and magnetic forces is a relative one with respect to the time-axis assumed; the two forces considered together can most vividly be described by a certain analogy to the force-screw in mechanics; the analogy is, however, imperfect."
Relative motion of the electrons will result in a magnetic field, but not because of length-contraction. It's because the electromagnetic field has a "screw nature". That's why we have the right hand rule:
GNUFDL image by Jfmelero see Wikipedia
See Wikipedia, and note the picture with the caption about screw threads. Maxwell also referred to this, see On Physical Lines of Force:
"A motion of translation along an axis cannot produce a rotation about that axis unless it meets with some special mechanism, like that of a screw".
Note that Maxwell used the word vortices in his page title, and that electrons have spin. So I will explain how this works using cyclones and anticyclones as an analogy for the electrons and ions. If you could set down a cyclone near an anticyclone, they move towards each other in a straight line, because counter-rotating vortices attract. But if you threw it past the anticylone, they also swirl around one another. When you only see linear motion, you call it an electric field. When you only see rotational motion, you call it a magnetic field. The difference is relative motion, so an electric field in one frame of reference is a magnetic field in another. For the current-in-the-wire, the linear motion caused by the electrons is counterbalanced by the linear motion caused by the ion, but because the electrons are moving, the rotational motions don't counterbalance, so the test particle moves around the concentric magnetic field lines. See this webpage for examples of electron motion in a magnetic field.