What problems with Electromagnetism led Einstein to the Special Theory of Relativity? I have often heard it said that several problems in the theory of electromagnetism as described by Maxwell's equations led Einstein to his theory of Special Relativity. What exactly were these problems that Einstein had in mind, and how does Special Relativity solve them?
 A: Maxwell's equations of electromagnetism predicted that light would 
travel with a constant velocity c. The question is - a velocity c with respect to what? It 
was thus supposed that it must be with respect to an ether which was at absolute rest in 
the universe. It then followed from the Galilean transformation that absolute uniform 
motion with respect to the ether could be detected. But all attempts to 
detect such motion have failed. The most famous experiment being Michelson & Morley's interferometer.
This led Einstein to his first postulate in the theory of relativity: "Absolute uniform motion cannot be detected by any means". This is to say that the concept of absolute rest and the ether have no meaning. 
And the second postulate was that light is propagated in empty space with a velocity c which is independent of the motion of the source. 
Einstein showed that in order for both postulates to be true we must modify our ideas about the nature of time.
A very nice example with a clock can be found in Feynman's lectures:
Suppose a simple clock built with two mirror pointing at each other (vertically), and a sensor which counts how many times the light bounced off of the mirrors:
An observer in rest would see the distance between these mirrors as L, and the time each tick takes $\Delta t = \frac{L}{c}$.
Now someone moving horizontally would see the path the light takes as $L^*=\sqrt{L^2+(v\Delta t^*)^2}$.
So he would see the counter tick in $\Delta t^*=\frac{\sqrt{L^2+(v\Delta t^*)^2}}{c}$
, so ${\Delta {t^*}}^2(1-\frac{v^2}{c^2})=\frac{L^2}{c^2}=\Delta t^2$ Which leads to Einstein's equation for time dilation: $\Delta t^* = \frac{\Delta t}{\sqrt{1-\frac{v^2}{c^2}}}$  .
This allows the speed of light to be constant in all reference frames, and solves the problem of the ether.
A: Even if the answers from CuriousOne, Terry Bollinger, Mr.WorshipMe are correct, the historical answer is not yet given. For instance, the invariance of the speed of light was not a problem, since this concept was not known before Einstein... who introduced it to define simultaneity ! 
As referred to the original Einstein's paper, the motivation for the introduction of the theory of special relativity was the so-called moving magnet and conductor problem. There is a wikipedia page about this "paradox" and the resolution Einstein gave to it. Also, the citation (and translation) of the introduction of the Einstein paper (on the electrodynamics of moving bodies) is given on the Wiki-page. 
In short, suppose a magnet (supposed charge-free) moves relative to a conductor, which hosts charges. If you're in the magnet frame, the Lorentz force $F=E+v\times B$ can only has magnetic component, since the electric field is only present in the conductor, and the charges are moving with velocity $v$. In contrary, when you choose the frame of reference of the conductor, the charges are not moving and the Lorentz force is purely electric. So the "paradox" is: why does something electric in one frame is magnetic in an other ? The resolution of the "paradox" is the Faraday law, which connect time-dependent magnetic field and electric flux.
The way Einstein resolved this "paradox" is by promoting all frames of reference to be the same in space-time (whereas Newton/Galileo mechanics defined all frames of reference to be the same in space only), and defining simultaneity. This led him to find the Lorentz transform.
Note nevertheless that the Einstein's motivation is not really resolved in his paper (a point that is not well discussed even at the present days). Indeed, there is no clear way to define relativity for solid bodies (especially elastic), and then the moving magnet and conductor problem is not yet understood correctly, except for point-like magnet and conductor. Also, if the magnet and conductor have a mass, they most certainly move with a small speed, and then most certainly we should define electromagnetism at low speed...
A: There was no problem with electromagnetism. The problem was that Maxwell's equations are invariant under Lorentz transformations but are not invariant under Galileo transformations whereas the equations of classical mechanics can be easily made invariant under Galileo transformations. 
The question was: how to reconcile both in a universe in which Maxwell's equations had been tested much more thoroughly than the equations of classical mechanics when $v$ is in the same order of $c$ and not much smaller. 
Einstein basically solved the problem by deciding that electromagnetism is more fundamental in physics, and then showing that classical mechanics could be modified in such a way, that it, too, became Lorentz invariant. As a side effect, he recovered classical mechanics as a natural limit for $v/c\to0$, which perfectly explained almost all observations of macroscopic dynamics available at that time (leaving Mercury's perihelion precession to be explained by general relativity ten years later). 
A: Actually it was that maxwellian electromagnetism had no problems, in contrast to the newtonian classical mechanics framework. Theory of Relativity alters the Newtonian framework not the Maxwellian framework.
i would say that even if Einstein hadn't invented SR, someone else would (as indeed many others notably Poincare, Lorentz et al) were alredy on the same track.
What caused the invention of SR (and similar concepts)? The advance of technology and the better understanding of electromagnetism (plus several techonological problems like clock synchronization in ships etc..).
Before electromagnetism was developed newtonian mechanics had no (serious) problem. They had an absolute space and time etc etc..
Then electromagnetism was developed (both as theory and as working technology) and the  problem of compatibility appeared.
Classical mechanics had absolute space-time references and not absolute velocities, whereas electromagnetism had the opposite.
To elaborate a little on this statement. According to Newtonian mechanics, there is an absolute space and time (thus absolute space/time references). However classical mechanics do not have a concept of absolute velocity. Indeed Newton's 1st axiom is a reflection of this (any constant factor can be added to a constant velocity and nothing will change). Classical mechanics do have a concept of absolute acceleration though. On the other hand the electromagnetic theory of Maxwell et al, predicts (and verifies) that electromagntic waves propagate at an absolute and constant velocity (now refered as the speed of light in vacuum $c$). Plus this implies (as SR mades explicit) that there are no absolute space-time references. In this sense it is the opposite of the classical mechanics framework.
Clearly for a coherent theory there had to be changes either to one framework or the other (or maybe both).
And indeed attempts were made in both directions.
The concept of Luminiferous aether and  other attempts, like Ritz's emission theory and Lorentz's aether theory worked to make electromagnetism compatible with classical mechanics, whereas Poincare, Einstein and others worked in the opposite direction.
Before we continue, which one is more likely to be wrong?? Classical mechanics, why? Because it was based on older methods, concepts, experiments, techonogy. While electromagnetism was based on newer technology, methods, experiments etc..
So in retrospect we could say the attempt to change classcial mechanics was better off.
Then the basic principles of Einstein's SR were these three observations:


*

*The velocity of light is constant (basic result of electromagnetism).

*The vecolity of light is an upper limit on material/signal velocities  (basic result of electromagnetism and conservation fo energy)

*The correct Maxwell-Lorentz transformations were derived from the first 2 principles and the relativistic velocity addition theorem. That is in essence the special theory of relativity. 
As Fra Schelle mentions (below), SR also includes (and expands) on the Galilean axiom (axiom 0.) that laws of physics are same in all (inertial) frames of reference.
This coupled with the mentioned observations make up the special theory of relativity, SR. Einstein of course, later, expanded this to include non-inertial frames of reference (general theory of relativity, GR) and in effect re-formulate gravitation as well.
A: In at least one history I've read about Einstein's early life -- sorry, I don't recall the name of the book -- the author claimed that even back when Einstein was in Gymnasium (high school), he pondered a simple thought experiment:

What would an electromagnetic wave look like if one traveled along beside it at the speed of light?

The answer from Maxwell's own equations was, well... nothing! For example, if you visualize a plane polarized light front as alternating orthogonal potential lines of electric and magnetic potential that simultaneously generate each other and extinguish themselves through their forward motion, that forward generation process disappears from the view of an observer who is also moving at c. Without that motion, the very process by which the wave propagates and stays in existence ceases to exist. Strange!
According to that Einstein biographer, it was this rather simple conceptual thought problem that got Einstein enamored with the problem of objects traveling near or at the speed of light. Einstein realized something very important was missing from the setup, and he set about figuring out exactly what it was.
Einstein was deeply respectful of Maxwell, whom he referred to as one of the greatest physicists of all time. The respect is well justified, since Maxwell arguably came rather close to figuring out relativity decades before Einstein. I think he might well have done so had he not died so young.
Certainly Maxwell's equations did far more than just hint at relativity. Their implicit inclusion of invariance under the Lorentz transformation practically shouted the need for a new perspective, and in effect outlined the mathematical details of what that perspective would have to look like. It just took an innovative new way of looking at the implications, specifically Einstein's insight that any frame is as good as any other, to wrap up the package in its full generality as the special theory of relativity.
