The magnetic force is weird. You're all familiar with bar magnets, which have a north and south pole. Opposite poles attract and like poles repel. But even though bar magnets are very familiar to us, they're relatively complicated, so we'll start with a more basic example.
A simple model of two wires. In each wire, the electrons (in blue) are moving to the left, while the atomic nuclei (in red) remain stationary.
Two wires. Wires conduct electric current, meaning that the negatively charged electrons move to the left or the right.* The positively charged atomic nuclei remain stationary. If the two wires have current going in the same direction, then they attract. If they go in opposite directions, then they repel.
*I am making a simplification, since this is not true for all materials that the wire could be made of. For reasons that I won't get into, some materials conduct electricity by things other than electrons.
Bar magnets are sort of like circular currents. If you have a north and south pole together, these currents are going in the same direction, and they attract each other. If you have a north and a north pole together, these currents are going in opposite directions, and they repel.
On the left, the circular currents (dark red arrows) are going in the same direction, making the magnets attract. On the right, the currents are going in opposite directions, making the magnets repel. Alternatively, we can think of the magnets as having north and south poles, where opposite poles attract and like poles repel.
But let's return to the wires, because they're simpler. The reason the wires attract is specifically because the electrons attract. One way we know this is the electrons tend to gather towards each other at the closer edges of the wire (this is called the Hall Effect). The electrons drag the rest of the wire with them, thus causing the wires to attract.
The reason why the electrons attract and the atomic nuclei don't is because that's just how the magnetic force works. The magnetic force is proportional to the speed of the particle. The electrons are moving, so they attract each other. The atomic nuclei are not moving, so they don't attract each other.
But hold on! Doesn't the speed of a particle depend on which way you look at it? What if you put these wires on a moving truck, won't all the electrons and nuclei be moving faster than before? For that matter, what if you put these wires on a moving Earth, doesn't that affect the speed? Why is it that we can use motors and generators (which both require magnetic fields) without worrying about the earth's motion?
This question was the motivation for Special Relativity Theory. You may have heard about Einstein's Theory of Relativity as something that radically alters our notions of space and time. But that wasn't really the point of the theory. The point was to explain something about magnetic fields. The radical view of space and time was just an added bonus.
Einstein's Special Relativity is sort of like an expansion of rotations. If you rotate your head 90 degrees, and look around you, several things change. Ceilings become walls and walls become floors. Right-left becomes up-down, and up-down becomes left-right. Everything that was pointing in one direction (like gravity, which originally pointed down) is now pointing in a different direction. But physics behaves the same way, just rotated.
The same is true if you're moving at constant velocity. If I'm on a moving truck, things that were previously stationary are now zipping behind us. If the air was previously still, it now becomes wind at our faces. But physics behaves the same way, it's just that directions have changed. In this case, we don't call it a rotation, we call it a boost.
According to Special Relativity, a boost does not just affect the motion of objects. It also affects the electric and magnetic fields. Just as right-left became up-down, and up-down became left-right when we rotated, electric fields can become magnetic fields and magnetic fields can become electric fields. It's not quite like rotation (the math is harder), but the idea is the same. A boost causes electric and magnetic fields to mix into each other.
And of course, it's not just electric and magnetic fields that mix into each other, it's space and time too. But at everyday speeds this is difficult to observe, because they're such small boosts. It's like rotating your head a fraction of a degree. What was once horizontal is still mostly horizontal (but with a slight vertical component). Similarly, at everyday speeds, what was once a distance is still mostly a distance (but with a small time component).
The mixing of electric and magnetic fields is deeply intertwined with the mixing of space and time. But this is very difficult to demonstrate without getting into the mathematics of boosting. There is one example where it is easy to demonstrate, and that is the example I started with. Two wires.
In a real wire, the electrons are not really moving at the same speed. But let's simplify and imagine that they are. And then let's boost to a perspective where the electrons are not moving at all.
Two wires, boosted.
After we've boosted, it is no longer the case that the electrons are moving left while the atomic nuclei are stationary. Now it is the electrons that are stationary while the atomic nuclei are moving right.
Since the magnetic force is proportional to speed, it can no longer affect the motionless electrons. But this is easy to explain in terms of Relativity: what was once magnetic fields have now changed into electric fields. The electric force causes the electrons in each wire to attract. The same electric force also cause the atomic nuclei to repel, but that's okay! The atomic nuclei have some speed, and are thus attracted by the magnetic force. The magnetic force and electric force on the nuclei cancel out.
So we really have the same picture as before. The electrons attract (but now due to the electric force, not the magnetic force), and they drag the entire wire along with them.
Now I will connect this to time and space.
If you look at my diagram, you'll notice I did something sneaky. After the boost, there are more nuclei than there are electrons. This is due to the mixing of time and space. Previously, the protons had some spacing, some distance between them. But as time and space mix, some of the distance changes into a time component, and the distance becomes shorter. It's called Lorentz contraction. When we boost from a frame where nuclei are stationary to a frame where they are moving, they become closer together.
Similarly, when we boost from a frame where electrons are moving to a frame where they are stationary, they become further apart. It's backwards Lorentz contraction.
The end result is that each wire now has a positive charge because the nuclei are more dense than the electrons. Electrons are attracted to positive charge by the electric force!
And so, there are two methods of solving the problem. The first method is to mix the electric and magnetic fields through the mathematics of boosting. The second method is to mix space and time, and then look at the resulting electric and magnetic forces. Both of these methods are equivalent.
Hold on! I know you have some questions.
Does that mean that the magnetic force isn't real? No. I'm not sure that it's meaningful to talk about whether these things are "real" or not. What it does tell you is that the electric force, magnetic force, and Special Relativity are all connected. Physics wouldn't make sense if you only had two out of the three.
What happened to the missing electrons? The number of electrons does not change when we boost, so they must have gone somewhere. The reason it seems they disappeared is because I only drew part of the wires. For a wire to conduct electricity, you need to have the wire in a loop to complete the circuit. The electrons will gather in the parts of the loop where they were going the opposite direction. There, they will be doubly Lorentz contracted.
What about two electrons by themselves moving alongside each other? In the wire example, electric and magnetic fields don't change over time. In the two electron example, they do change over time. This significantly complicates the way things work. But suffice it to say that the faster the electrons move, the stronger the electric force repelling them. The magnetic force between the electrons is counteracted by this stronger electric force.
Aren't the electrons all moving at different speeds? Yes. But it works out the same. It makes the math a lot more complicated. The entire premise of this post is to simplify to an example where I don't have to show that. If you would like to see it, you should be studying physics academically, not from blogs.
Is Lorentz contraction really that big? No. I exaggerated it so you can see it clearly. In a typical wire, the electrons are moving with an average velocity of 10-5 meters per second, which corresponds to a Lorentz contraction of 1 part in 1027. If it seems impressive that such a small Lorentz contraction can create a measurable force, that's because it is.