In our daily life a lot of photons of visible light, infrared and radio etc move around us. We know that light is an electromagnetic radiation. So why doesn't that electromagnetic radiation affect a magnetic compass?
3 Answers
Most electromagnetic radiation is of very high frequency - the magnetic field changes many times per second. This means that the compass just doesn't have time to "follow" the magnetic field changes.
The only thing that does affect a compass is a DC magnetic field - usually this is a large piece of iron etc. that gets magnetized (e.g. by the earth's magnetic field) and thus causes distortion; or it can be a DC current loop of some kind.
But even the low frequencies of the mains (50 or 60 Hz depending on where you live) are much too fast to affect the compass (although in the presence of a strong source of electromagnetism, such as a large transformer, you can see vibration in the needle as observed by @vsz). Radio starts in the kHz (for long wave) to MHz (FM) or GHz (WiFi etc). And light, with wavelengths around 500 nm and a speed of 3x10$^8$ m/s, has frequencies in the hundreds of THz range. Too fast.
UPDATE - adding a bit of math(s):
A compass in the earth's field can be thought of as a damped oscillator: on the one hand there's the torque on the needle that is proportional to the displacement from magnetic North, on the other there's the inertia of the needle; and finally, there are damping terms (a good compass is critically damped - meaning that the damping is such that it will go to the right position in the shortest time). We can write the equation of motion as
$$I\ddot\theta + \mu\dot\theta + k\theta = 0$$
In this expression, $\mu$ is the damping term (proportional to the angular velocity) and $k$ is the factor that describes how much torque the needle experiences with displacement.
This is a general equation for a Simple Harmonic Oscillator (SHO), and we typically recognize three regimes: lightly damped, heavily damped, and critically damped.
How such an oscillator responds when you give it a displacement and then let it go depends on the kind of damping - see this graph:

In particular, the critically damped oscillator converges to its equilibrium position as fast as possible - which is why it's preferable for things like a compass.
Now when you drive a SHO with an oscillating force, you get a response that depends on the frequency of the drive signal and the natural frequency of the system. If you drive at the natural frequency, you get resonance and the amplitude becomes large; as the difference in frequency gets larger, the amplitude of the response gets smaller. For a lightly damped (or underdamped) system*, the amplitude response is given by
$$A = \frac{s_0}{\sqrt{\left[1-\left(\frac{\omega_d}{\omega_0}\right)^2\right]^2 +\left[\frac{\omega_d/\omega_0}{Q}\right]^2}}$$
In the limit of large frequencies, the response scales with
$$A \propto \left(\frac{\omega_0}{\omega_d}\right)^2$$
where $\omega_0$ is the natural frequency $\sqrt{\frac{k}{I}}$ and $\omega_d$ is the driving frequency. When the driving frequency is many orders of magnitude larger than the natural frequency, the amplitude response will be negligible.
As was pointed out in a comment by MSalters, at extremely high frequencies (above 10 GHz) the wavelength of the EM radiation becomes short compared to the length of the compass needle, so the above is further complicated by the fact that different parts of the needle will experience forces in different directions. All of which points in the same direction: the needle won't move.
* I am taking the easy way out here... did not find the expression for the critically damped driven oscillator and don't have the intestinal fortitude to derive it right now and trust myself to get it right. But this is 'directionally correct' even for critically damped oscillator
- 119,981
The frequency is one very good argument (and I guess the most important factor) but it might be worth also looking at the magnitudes of the fields.
The earth's magnetic field has a strength of roughly $31µT$. The intensity of the sunlight hitting the earth is about $1300W/m^2$. Since the intensity is related to the electric field $E$ of an electromagnetic wave in the following way $$I=\frac{1}{2}\epsilon_0 c E^2 $$ and the magnetic field strength is given by $B=1/c \times E$, one can easily calculate that the magnitude of the magnetic field is given by $$B\approx 3.3 µT.$$ So the earth's magnetic field is roughly ten times stronger. But: It can now be argued that fields with higher intensity would have greater impact. Now the frequency argument rescues us and in fact this argument seems to be the correct one, as one does not notice a deflection of a compass needle in the presence of a strong laser.
- 769
Basically the same reason as what Floris said, but this also has another important aspect:
Visible light has a far too small wavelength to affect a compass. Not only does the field oscillate too quickly around an average of zero – even at any single “snapshot” in time of the electromagnetic wave, there would nowhere be a large region where the field points in one direction. Only fractions of a micrometer are exposed to a field in a single direction; move a hair-width and the field may point in the opposite direction. Overall, at any given time, the forces on all parts of the needle cancel almost completely. So even if the light frequency wasn't to high for the needle to follow, it would still not move.
- 15,157