Why does Webb need to be at L2?
Webb requires a distant orbit for several reasons. Webb will observe primarily the infrared light from faint and very distant objects. But all objects, including telescopes, also emit infrared light. To avoid swamping the very faint astronomical signals with radiation from the telescope, the telescope and its instruments must be very cold (Operating Temperature: under 50 K (-370 deg F)). Therefore, Webb has a large shield that blocks the light from the Sun, Earth, and Moon, which otherwise would heat up the telescope, and interfere with the observations.
To have this work, Webb must be in an orbit where all three of these objects are in about the same direction. The most convenient point is the second Lagrange point (L2) of the Sun-Earth system, a semi-stable point in the gravitational potential around the Sun and Earth. The L2 point lies outside Earth's orbit while it is going around the Sun, keeping all three in a line at all times. The combined gravitational forces of the Sun and the Earth can almost hold a spacecraft at this point, and it takes relatively little rocket thrust to keep the spacecraft near L2. The cold and stable temperature environment of the L2 point will allow Webb to make the very sensitive infrared observations needed.