Here is a paper I wrote and put in my last book The Great Noetic Filter:
It is all about how to derive the adiabatic gradient from first thermodynamic principles, and it addresses the claim that the troposphere should be isothermal – it should NOT be. Maxwell and Boltzmann, from where the isothermal claim is derived, assumed a fixed enclosure surrounded by a constant and infinite heat bath: it is that assumption which sneaks in a constant temperature from the outset, and a constant temperature is the only possible result from those premises. But those premises are not the atmosphere. The air is not fixed in an enclosure: it is free to expand and rise; the air is not surrounded by a constant heat bath: there is periodic heat at one extremity, there is no surrounding bath, and otherwise in equilibrium there is zero heat flow.
The other problem is that the typical explanation invokes bulk convection, using phrases like “consider a parcel of gas rising or falling”. However, something is left out: what replaces that rising or falling parcel? Is vacuum left behind? And what do we mean by parcel? A fixed volume? A fixed mass? The correct way to handle this problem is with an infinitesimal slice of space, and to consider the gas which moves through the slice, and the gas can move through it with no bulk convection because there is still always thermal motion from the Maxwellian speed distribution. So, the rising and falling parcels actually have to be sieves if the atmosphere is mechanically stable, with air rising and falling simultaneously. Use an infinitesimal slice for that.
Here is the paper. It fully derives the temperature structure of the troposphere from standard thermodynamics, leaving no temperature residual for a radiative greenhouse effect to have to come in to explain, let alone entirely replace: