Because it is an infrared telescope, and in earth orbit there are three very bright infrared sources that would mess up the instruments or heat up the telescope too much if they ever shone on the sensitive parts. (Sun, Moon and Earth.) When the telescope is placed in the Sun-Earth L2, all three sources are always very close to each other in the sky, and you can shield against all three with a single directional sunshield.