This question strikes at one of the most active areas of current astronomical research. Not surprisingly, several scientists wrote in to give their answers.
David Van Blerkom, a professor of astronomy at the University of Massachusetts at Amherst, provides a nice overview, focusing on the second part of the query:
"The fact that the outermost region of the sun's atmosphere is at millions of degrees while the temperature of the underlying photosphere is only 6,000 kelvins (degrees C. above absolute zero) is quite nonintuitive. One would have expected a gradual cooling as one moves away from the central heat source. A related question is why, if the corona is so hot, it does not heat up the photosphere until it has an equally high temperature.
"I will address these questions in reverse order. Let us first ask what it means for a gas to have a high temperature. The answer is that temperature is a measure of the average kinetic energy of the gas atoms, that is, a measure of how fast they are moving. A high temperature gas has atoms with a larger average velocity than a low temperature gas of the same composition. We thus infer that the atoms in the corona are moving much more rapidly than those in the photosphere.
"In order for the corona to make the photospheric temperature rise, the coronal gas must cause the photospheric atoms to move faster. It could do so by colliding and mixing with the cooler gas and thus transfering some of its kinetic energy. Another way is also possible: At a temperature of millions of degrees, the gas in the corona is highly ionized, that is, electrons are stripped off neutral atoms and move freely. Because electrons are thousands of times less massive than atoms, the hot electrons have very high speeds. These electrons could travel into the photospheric gas and collide with the atoms there, again increasing their velocities. These two heating mechanisms are called convection and conduction, respectively.
"A gas at millions of degrees also radiates energy; much of it is emitted in the form of very high-energy x-ray photons. X-ray photons impinging on the photosphere could also transfer energy to the gas atoms there. This heating mechanism is radiation.
"Yet the three traditional methods of heating do not raise the photospheric temperature for a simple reason. Suppose, as a thought experiment, one had a thermometer that could measure temperatures of millions of degrees and placed it in the corona. In order to make a temperature measurement, the coronal atoms or electrons must strike the thermometer, or x-ray photons must impinge upon it. The corona, however, has such a low density that the thermometer will almost never be hit. So while the thermometer is technically sitting in a gas that is at 2,000,000 kelvins, it doesn't know it. The gas has a high temperature but a low heat content. There are just not enough atoms around to heat our hypothetical thermometer or the underlying photosphere.
"The question of why the corona has such a high temperature is harder to explain, and probably the last word on the physical mechanism has not yet been given. Most astronomers assume that the gas is heated by the magnetic field that pervades the corona. The solar magnetic field has long been known to cause the sunspot cycle, and the physical shape and activity in the corona also varies with the sunspot cycle. Magnetic fields are known to be able to transfer large amounts of energy to the solar atmosphere, sometimes explosively as in flares. Huge magnetic loops can be seen to rise far into the corona, and it is quite plausible that the solar magnetic field is the ultimate source of physical heating of the corona."
Vic Pizzo of the Space Environment Center in Boulder, Colo., reiterates how mysterious this process is:
"The precise mechanism by which the corona overlying the solar surface is heated to temperatures of one to two million kelvins remains one of the outstanding problems of solar physics. It has long been suspected that turbulent motions in the lower solar atmosphere are propagated outward as waves in some form, which ultimately shock the thin atmosphere above the surface (the photosphere). The shocks thereby dissipate mechanical energy in the waves as heat. When magnetic field lines reconnect, they release energy; some researchers suspect that fine-scale magnetic reconnections above the sun's surface provide the energy to heat the corona.