A hot object gives out more light than
a cold object. This makes sense - the hotter something is, the more energy
it has, so it gives off more energy as light. Hot objects also give out
light of a different wavelength from cold objects.
This is a tough question and folk that do solar physics still cannot explain it properly. One idea goes like this. All the energy of the Sun is produced in nuclear reactions at its centre. This energy seeps out through the whole Sun and eventually reaches the surface - the photosphere. This energy keeps the photosphere as hot as 5,500oC. But, in sunspots, the magnetic fields are very strong and they stop some of the energy getting to the surface. Since they get less energy, sunspots are cool.