Why it is that high altitude areas are colder than low altitude areas? Is it because the air pressure or any other? If we consider it with the sun rays, high altitudes receive sun rays earlier than low altitude so low altitudes must receive rays with less amount of energy relative to high altitude rays. Therefore low altitude must have low temperature. Can any one explain theory behind the scene?
The principal physical mechanisms in the troposphere, stratosphere, etc are different. Since it's the troposphere where we live, and where weather occurs, let's guess that's what you're asking about.
Then google adiabatic lapse rate for the somewhat elaborate thermodynamic explanation that's been exhaustively studied and worked out over the last hundred-plus years.
As often, wikipedia's https://en.wikipedia.org/wiki/Lapse_rate isn't a bad place to start. In particular, note the pretty straightforward derivation from the first law of thermodynamics in the https://en.wikipedia.org/wiki/Lapse_rate#Convection_and_adiabatic_expansion section. The first three paragraphs of that section contain an extremely clear and concise words-only explanation, which is then followed by the corresponding math.
- The greater the altitude, the further the air molecules are from the ground. This means that there is a weaker gravitational force, leading to air molecules accumulating at lower altitudes. Thus, less molecules are at higher altitudes, so they retain less heat. Hence, it is colder at higher altitudes.
- Air also contains dust and water molecules, which trap heat. However, the weaker gravitational force at high altitudes and stronger gravitational force at lower altitudes cause these molecules to be present in smaller amounts at higher altitudes. This will allow heat to escape more easily at higher altitudes, and thus trapping less heat, leading to a lower temperature at higher altitudes.
You said: "If we consider it with the sun rays, high altitudes receive sun rays earlier than low altitude so low altitudes must receive rays with less amount of energy relative to high altitude rays. Therefore low altitude must have low temperature. Can any one explain theory behind the scene?"
However, you have ignored the fact that gravity is different at different altitudes. Furthermore, the distance between different altitudes is negligible when compared to how far the light from the sun travels before reaching Earth. Hence, the about of heat and light energy received at different altitudes is negligible. Thus, gravity is the main factor here.