The telescope is designed to image very faint sources of infrared light. The problem is that everything (including the telescope itself) glows in infrared. The hotter things are the more infrared they emit. Because of this you want to keep the instrument as cold as possible. (You do this because you don’t want to drown the faint sources by the glow of the telescope itself.)
Now of course there are parts which has to be “hot”. At least relatively to the very cold instruments. The solar panels are heated by the sun, the transmission electronics and the processing turns electricity into heat. The positioning thrusters burn chemicals which makes them hot.
Because of this they designed the spacecraft with two sides, a cold one for the instrument and a hot one for everything else. They even choose the orbit cleverly so they can keep the sun and the earth and the moon always on the hot side of the vehicle.
And then you have this problem that you have to make sure that the hot side won’t warm up your cold side. This is where the heat shield comes into play. Sometimes it is also called a sun shield since the sun is the main source of heat for it to shield against of course, but it also shields the instrument from the heat of the hot side equipments.
Structurally it is a 5 layer lassagne. They just replaced the pasta with metalized kapton tape and the sauce with the vacuum of space. It is about the size of a tennis court, launches folded up and will un-fold in space. Hopefully. :)
[1] https://webb.nasa.gov/content/observatory/sunshield.html