Answer Explanation
Could you please quote where you have read that the temperature in the upper atmosphere is higher than that of the earth? I do not think so - it is less than the temperature of the earth in my opinion.
I can however explain why the upper atmosphere is cooler than the earth's surface.
Most of the energy from the sun arrives at the earth in the form of light energy, or short-wave energy. The atmosphere is transparent to
short-wave energy, and most of the solar energy reaches the surface of the arth, where it is absorbed. This energy warms the surface of the earth, which, in turn, warms the atmosphere with long-wave energy. The type of energy radiated by a star primarily depends on the temperature. So the energy from the sun arrives at the earth as short-wave (in the visible part
of the spectrum) energy, and leaves the earth as long-wave (in the infra-red part of the spectrum) energy.
The atmosphere is not transparent to long-wave radiation, and absorbs the heat energy from the earth. That part of the atmosphere closest to the earth gets the most energy and is the warmest. The part of the atmosphere farther away from the earth's surface is cooler.