Had to look it up because I never realized it either. So the telescope would orbit the L2 node outside the shadow (solar panels need light) but all the bright things in the sky will stay right where they belong behind the sun sheild.
Webb primarily observes infrared light, which can sometimes be felt as heat. Because the telescope will be observing the very faint infrared signals of very distant objects, it needs to be shielded from any bright, hot sources. This also includes the satellite itself! The sunshield serves to separate the sensitive mirrors and instruments from not only the Sun and Earth/Moon, but also the spacecraft bus.
The telescope itself will be operating at about 225 degrees below zero Celsius (minus 370 Fahrenheit). The temperature difference between the hot and cold sides of the telescope is huge - you could almost boil water on the hot side, and freeze nitrogen on the cold side!
To have the sunshield be effective protection (it gives the telescope the equivalent of SPF one million sunscreen) against the light and heat of the Sun/Earth/Moon, these bodies all have to be located in the same direction.
This is why the telescope will be out at the second Lagrange point.
Heat problems in space are so weird when you're used to thinking about an atmosphere.