Dark spots on the sun where the gas is cooler are called sunspots. The general theory behind sunspots is that the magnetic fields in the region have become all twisted and tangled as the gas in the sun moves around. This tangle interferes with the orderly motion of underlying convection cells. These convection cells are rising streams of hot gas that move energy in from the hot core of the sun (where the nuclear fusion generates energy) up to the surface. This is just like how boiling water has hot spots that rise to the surface and cause it to roil and ripple.
By hampering these convection cells the magnetic fields essentially reduce the amount of heat and energy that the spot on the sun receives, allowing it to cool and appear dark compared to its surrounding area.
The surface of the sun is normally ~5,000 degrees C, while a sunspot is ~3,500 degrees C. That's still hot, but enough of a difference that it appears dark in comparison.