Sunspots are regions of strong magnetic field on the surface of the Sun. Magnetic field is generated 200,000km below the surface at the base of the convection zone. The convection zone is the name given to the outer 30% of the solar interior where energy is transported to the surface via convective motions: same as heating oatmeal on a stove - hot oatmeal rises distributing its heat throughout the pot, the cooler oatmeal sinks to be heated at the bottom to rise and cool and so on. When the magnetic field becomes strong enough it becomes buoyant like a hot air balloon and rises up to pop through the surface. Where is comes through it forms a sunspot.
Cheers - David