The troposphere is the layer of the atmosphere closest to the earth's surface where the weather takes place. The warmest temperatures in the troposphere are near the surface with the coldest temperatures being at the top of the troposphere. Although the sun light comes from the top to the bottom of the atmosphere, the troposphere is primarily heated from the bottom. This is because the surface is much better at absorbing a wide range of solar radiation as compared to the air. Much of the sunlight filters down through the air and to the surface. Certain gases do absorb radiation and warm the air such as carbon dioxide and ozone. However, a great amount of solar radiation makes it to the surface. The surface is warmed by the sun and then this energy is distributed upwards into the troposphere through a mixing of the air. Since the earth's surface is the primary heat source, temperatures will be warmest at the surface and decrease away from the surface. The average temperature profile of the troposphere will show a decrease in temperature with height. This does not mean that in certain weather situations that the temperature can not increase with height since it does in the case of inversions. Since on a typical day the temperature decreases with height rather than an inversion being in place, the average profile is a temperature decrease with height.
Since the temperature decreases with height in the troposphere it can be easy for air to rise vertically since cooler air over warmer air is an unstable situation. When air rises it cools adiabatically. This is another reason the temperatures are colder aloft than at the surface. For air to rise to a higher elevation it must cool. Air density and pressure is highest at the surface. When air rises it expands since the pressures are lower aloft. Expanding air cools.
Because the sun primarily warms the troposphere from the surface and because air cools as it rises, the warmest temperatures in the troposphere on average are at the earth's surface.