The phenomenon is called adiabatic heating/cooling, where “adiabiatic” means no heat transfer. The heating and cooling is caused by mechanical work being done to compress the air (or mechanical work being done by the expanding air). The energy added/removed is manifested as a change in temperature. This is why diesel engines work: the piston compressed the air, it heats up hot enough so that when you inject fuel, it ignites.
If you’ve ever used a hand pump to inflate a bicycle tire, you may have noticed it can get pretty warm, especially right at the tire valve stem. Same thing: you’re compressing the air, doing mechanical work to make that happen, and the result is that the air heats up.
So imagine a plane cruising at 37,000 feet. At that altitude, ambient pressure is about 3.14 psi, temperature -63F. The cabin is kept at a “pressure altitude” of about 5000 feet - that is, the pressure is kept the same as you would feel if you were on the ground in Denver, about 12.26 psi.
When you take air at 3.14 psi and compress it to 12.26 psi, it heats up. A lot. The equation is thus:
T[sub]2[/sub]/T[sub]1[/sub] = (P[sub]2[/sub]/P[sub]1[/sub])sup/1.4[/sup]
Make sure your temperatures are on an absolute-zero scale, so T[sub]1[/sub] is actually 396 Rankine, instead of -63F. Anyway, solve for T[sub]2[/sub] and you end up with 584 Rankine, which is equal to 125 degrees Fahrenheit. That’s pretty damn hot, so yeah, you have to cool that air off before you dump it in the cabin.