Imagine an isolated bubble of air heated by the ground and bobbing upwards. As it climbs the pressure falls and so the bubble expands to equalise its pressure with the air around it. To expand, the bubble must exert a force on the surrounding air and move it away. The work done requires energy and the only source is the internal molecular energy or heat content of the bubble's air. The internal energy decreases and the temperature, which is purely the measure of it, falls*.
The bubble will rise until its temperature is the same as the surrounding air. If we visualize the atmosphere as made up entirely of such bubbles we see that they would rise and descend until a natural equilibrium state is reached where the temperature falls smoothly with increasing height**.
If the air were never heated by solar radiation its temperature would continue to fall as we climb. However, at a height of ~12 km a minimum of ~-55°C is reached, the tropopause***. Above that the temperature starts to increase again because the stratospheric air contains a sunlight absorber, ozone.
The tropopause minimum acts as a barrier^ between the troposphere and stratosphere because mixing and heat transport by convection can only occur when temperature decreases with height. The troposphere - with convection allowed - is turbulent and well mixed. The stratosphere with its temperatureincrease with height is stable, stratified into layers and relatively poorly mixed^^.
At high latitudes the tropopause and lower stratosphere temperature can plunge to ~ -85°C to provide the conditions for PSCs, polar stratospheric clouds of which the incredibly bright and colourful nacreous clouds are a subset.