The problem is that the temperature of the corona is between one and three million kelvin, whilst the temperature of the surface is much, much cooler, only about 6000K.
There doesn’t seem to be any good explanation as to why the region above the surface is hotter than the surface itself. The Second Law of Thermodynamics says that thermal energy cannot flow from the cool surface to the hot corona so a different explanation is needed.
There are two competing theories as to what is responsible: wave heating, and magnetic reconnection. The first, wave heating, says that energy is transferred by waves in the plasma a bit like sound waves; the second, magnetic reconnection says that energy is released as electrical currents induced by the collapse of the Sun’s magnetic field. This is the same phenomena that creates coronal loops like the one shown in the photograph below.
Most scientists think that a combination of the two theories is responsible; it is hoped that NASA’s Solar Probe+ will solve the coronal heating problem for good.