Victor Pizzo, a physicist at the National Oceanic and Atmospheric Administration's Space Environment Center, explains.
The fact that the sun's corona is very hot--one million to two million kelvins in "quiet" regions, two million to five million in magnetically strong active regions and higher yet in solar flares--was well established by the 1940s. Temperatures in the cooler photosphere (the visible surface of the sun, where we see sunspots) and the overlying chromosphere (where we best see prominences and the expanding magnetic structure in the lower solar atmosphere) had been determined long before that by spectroscopic observations. For example, the characteristic brilliant red of the chromosphere seen during solar eclipses was readily traced via so-called Balmer line emissions from hydrogen to material at around 6,000 kelvins. Astronomers recorded red and green line emission from the corona during eclipses as early as 1867, but they could not associate them with any known laboratory spectra. For a time people speculated that the coronal emissions were due to coronium, a potential new element found only in the sun. Finally, however, it was recognized that the observed color lines arise from what are known as forbidden emissions from very hot atoms (in the range of one million K or more) occurring under highly rarified conditions. That is, only in an ultra-low density medium, such as the corona, are collisions between atoms so infrequent that atomic populations can be maintained in the right kind of energy states to enable the observed emission.
Although these high coronal temperatures came as a surprise to early observers, it did not take long for theoretical explanations to surface. They fall into three main categories: In the first, the photosphere can be likened to the bubbling surface of boiling water; it is a seething mass of rising and falling columns of hot fluid. And just as the roiling water makes noise, so does the convective overturning of the solar surface fill its atmosphere with intense sound waves. Thus, if you could stand on the solar surface, not only would it be very hot but it would also be incredibly loud. At least some of this sound makes its way upward into the corona, where dissipative processes covert the audio energy into heat. Because the coronal material is so thin and tenuous, only a tiny portion of all the sound energy in the photosphere needs to bleed up into the corona and be absorbed in order to heat it to the observed temperatures.
The second theory is really just an elaboration of the first. The bubbling fluid of the photosphere is threaded by magnetic fields, some of which are many thousands of times as intense as Earth's field, but most of which are a good deal weaker. (The fields located near sunspots are the strongest.) The presence of this magnetic field enables the energy from the boiling motion to propagate upward in a variety of ways as magnetohydrodynamic waves. These are analogous to pure sound waves, but their properties depend on the magnetic field strength and direction. Some of these waves allow for particularly efficient transmission and deposition of energy and so are favored by many theorists as the corona's heating source.
The third explanation is quite different. In this case the heating is thought to arise from the interaction of the magnetic structure in the lower solar atmosphere with the convective motions mentioned above. The near-surface layers of the sun comprise countless small and large loops of magnetic flux, looking something like the field lines connecting the poles of a bar magnet. As the boiling motion twists and pushes the foot points of the field lines around, strong electric currents are induced along the field lines. The surface layers can thus be viewed as a mass of current-carrying wires, which come to be twisted and braided into a hopelessly tangled mass. Eventually, by a process known as reconnection (which can be thought of as a short-circuiting of the wires), the field lines rearrange themselves into a simpler pattern. In this process, large amounts of energy are released to heat the corona.