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.
At the very least, all these hypotheses appear capable of explaining the observed magnitude of coronal heating. Yet the detailed observations needed to distinguish among them have not been made. In addition, there are other unrelated theories of heating (the decay of neutrons leaking out from the sun, dissipation of heretofore unobserved massive subatomic particles, and so forth) that cannot be ruled out with existing observations or theoretical understanding. More than half a century after the corona was determined indisputably to be very hot, there is no consensus as to which particular mechanism or mechanisms actually does or do the heating.
Indeed, given current remote sensing techniques, a conclusive resolution of all these hypotheses may not even be possible. The surest course would be to sample directly the actual plasma in the solar atmosphere to as low an elevation as practical. This would entail careful measurement of the distributions of electrons and ions in terms of both direction and speed across a range of heights in the corona. The various mechanisms described above are thought to leave telltale signatures that would be evident in such measurements. A spacecraft mission to accomplish precisely this goal has been in the works for several decades now, but the technological difficulties involved are both daunting and costly to overcome. No matter what the mission concept, the spacecraft and its instrumentation would be subjected to enormous amounts of heat during the approach to the sun, so the pass through the solar atmosphere would have to be done quickly. Not only would spacecraft survival be a difficult proposition, but even the capture of meaningful data (and its transmission to Earth) would be a major challenge. You can read more about what a prospective solar probe mission could look like via the link provided below.
Hopefully, some time in the near future, funding will become available to support such a mission to finally resolve the mystery of coronal heating.