Does special relativity explains working of an electromagnet? 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?
I also heard that it is based on the principle that-electric field in one frame of reference is magnetic field in other.
How is it? (I am still in high school, so I don't know much advanced maths and physics.)
 A: I got caught up trying to find the answer to this question after watching the Veritasium and MinutePhysics videos mentioned in other answers. I would highly recommend watching them as they get the big picture and have some nice visuals. There is some debate in these forums regarding the accuracy of the videos' explanation, but after going through the video, its sources, and the criticism, I still believe the argument is valid.  This post is based largely on the videos, and also checking the video's reference Purcell (2nd ed. pp 178-181 & 192-199), and the Feynman lectures 13-6 for good measure. See either of these for more details.
Similar discussions that are worth reading (some directly relating to the videos) can be found here, here and here.
Electric fields and magnetic fields are both manifestation of the same phenomenon, seen from different reference frames. 


*

*Imagine you have a wire full of equally many positive and negative charges. The wire is neutral. You have a positive test charge outside of the wire. Since the wire is neutral, it experiences no electric force. Since it is not moving, it does not experience a magnetic force. 

*You start a current, making the negative charges flow to the right. Because of special relativity and length contraction, the negative charges are "squished together" slightly in the direction they travel, compared to their length in their rest frame (the frame where they are not moving).The wire will be negatively charged, since there are more negative charges per length unit than positive ones. Compensate for this by giving the wire a positive charge so that it is still neutral in the lab frame. Your test charge experiences no electric force, since the wire is neutral. It experiences no magnetic force since it is not moving.  

*Get your test charge moving, in the same direction as the current, with the same velocity v for convenience. Since there is a current going through a wire, there is a magnetic field, and we can find its direction by the right hand rule. Since our test charge is moving in a magnetic field, it will experience a force. We can find this force using F=qvB, and using the right hand rule we find it is pointing away from the wire. There is still no electric force, since the wire is neutral. 

*Now move to the reference frame that is moving along with the test particle. Here, the negative charges are still, and the positive charges are moving to the left. So there is still a current, but since the charge is not moving in this frame, there is no magnetic force. However, the positive charges are moving in this frame, so they will squish due to length contraction. At the same time, the negative charges will "un-squish", as we are now in their rest frame. The net result is that the wire is positively charged. The test charge will be repelled by an electric force. 
So we see that what appears as an electric force in one reference frame, appears as a magnetic force in another. This way, special relativity connects the two seemingly different phenomena, and show that they are two sides of the same coin.
One of the big questions I had when seeing this, was that this explanation can only account for repulsion or attraction,, not the helical motion we know we get in magnetic fields (e.g. with charged particles entering the Earth's atmosphere and causing the northern lights). However, there is a relativistic mechanism based on a similar idea that accounts for the force changing direction as we expect it to in a magnetic field. It has to do with the way electrical fields transform between reference frames, but it is a more involved proof that I don't think I can re-tell in a meaningful way. This case provides the intuition for how relativity links magnetism and electric force; see Purcell (2nd ed. pp 178-181 & 192-199) if you want the details on how it works when the motion of the particle is not parallel to the wire.
A: The laws of the EM (electromagnetic) fields contradict the classical Newtonian mechanics. For example, switching reference frames would change the speed of the EM waves, while Maxwells' Equations (and the experimental evidence) result the speed of the EM waves are constant $c$.
This was one of the reasons of the development of the Special Relativity (SR).
In the CM, there are different laws to describe the interaction of moving things and the electric/magnetic forces (f.e. Faraday's law of induction). In the SR framework, the Lorentz-tranformation transforms electric fields to magnetic and vice versa.
Electric engineers study the theory of the electromagnetic fields in non-relativistic approximation belonging to practical scenarios (EM field around a high-voltage wire, EM field in an electric motor, transformator or electromagnets). But they can do this efficiently only after they learned its SR background.
In the practical electromagnet design, the engineers use the classical EM laws and classical mechanics - and a lot of highly complex technical experience collected since centuries.
Thus, SR explains much better, how an electromagnet works, but the CM version is used in the daily design practice.
A: 
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.     
