The temperature gradient in a star determines the rate at which radiative diffusion transports energy out of a star. If this gradient becomes steep enough, the plasma in this region becomes unstable to convection. Convection therefore sets a bound on the temperature gradient in a star. Because convection imposes a constraint on the temperature gradient, it imposes a limit on the amount of energy transported by the diffusion of radiation; convection is the dominant mechanism for transporting energy in convectively-unstable regions.
The mechanism that gives rise to convection is the same for all pressure-supported atmospheres trapped in a gravitational potential. If a gas in a gravitational potential is static, then the pressure at any point within the gas is equal to the pressure exerted by the overlying material. The temperature and pressure, however, are set by other factor, such as the radiative transport of energy. For an ideal gas, such as is found in the interior of a star, the gas pressure increases with either an increase in temperature or density. A volume of gas of any temperature can therefore be in pressure balance with its surroundings if the density is adjusted to compensate. For instance, if a particular volume is hotter than its surroundings, then its density will be lower than its surrounds. It is this property that drives the convection, because the lower-density region is buoyant, and it will rise to a higher altitude.
Whether or not a region is unstable to convection depends on the precise temperature structure of the region. Let us assume, for instance, that a gravitationally-bound gas has a pressure, temperature, and density that drop with altitude. What happens when we take a small volume of this gas and push it to higher altitude? Does it sink back to its original position, or does it keep rising? If the first occurs, the gas is stable to convection; if the second occurs, the gas is unstable to convection.
When our volume of gas is lifted to a higher altitude, the gas expands to maintain pressure balance with its surroundings. This expansion decreased not only the density, but the temperature, because our gas volume is doing work on its surroundings as it expands. If the temperature drops faster than the temperature of the surrounding gas, the density of our volume will be greater than that of the surroundings. The volume would therefore be less buoyant, and would sink back into place. But if the temperature of our volume is greater than the surrounding temperature, the density of the volume will be less than that of the surroundings, and our volume would be more buoyant than the surrounding gas. Our volume would continue rising, and convection would commence in the gas. The atmosphere in this case is unstable to convection. From this we see that the stability of the gas is dependent on the temperature gradient. If the temperature gradient becomes too steep, convection begins.
This thought experiment shows that the density of a star must decrease as one moves out from the core to the surface. In a star, the pressure decreases as one moves outward, because the pressure is set by the weight of the overlying layers. If we take our volume element and move it up, both the density and temperature of the element must drop to achieve this lower pressure: the density drops because of the expansion, and the temperature drops because of the work done on the surroundings during the expansion. But if the surrounding density is constant or is increases with altitude, then our volume has a lower density than does the surroundings, and it is more buoyant than the surrounds. A density that increases with altitude is therefore unstable to convection.
In our thought experiment of lifting a gas volume to higher altitude, we are defining a temperature structure for the atmosphere through an adiabatic process, which is defined as a process where no heat is exchanged with the surroundings. If the actual temperature over a region of a star falls faster than this adiabatic temperature, the region is unstable to convection.
Most stars have regions of convection. In a main sequence star that are the size of the Sun or smaller, this region is in the outer layers of the star. In a main sequence star that is more massive than the Sun, the core of the star is convective.
Convection is important not only because it transports energy, but because it mixes the gas in a star. For stars with convective cores, the products of nuclear fusion are mixed with lighter elements from regions not supporting nuclear fusion. This mixing prolongs core nuclear fusion in a star.