In normal subsonic flying, as air gets thinner, it means there is less lift but also less drag, which can be made up for by going at a higher speed.
So to get maximum range and speed, planes fly as high as possible.
(Other factors may weigh against this, such as headwinds being faster at higher altitude.)
Piston engines generally require turbochargers at high altitude, because there's less partial pressure of O2.
(Turbine engines are turbochargers.)
In terms of range for given fuel, it is well-discussed here.
Just note that
Jet engines are characterized by a thrust specific fuel consumption,
so that rate of fuel flow is proportional to drag, rather than power.
The other thing that happens is aircraft can come up against the Q-corner.
This means that, while with a given indicated air speed, they are actually going faster because the air is thinner, the speed of sound actually decreases with altitude.
Since subsonic aircraft must stay well below Mach 1, it means as they go higher they must also reduce indicated airspeed.
When they get caught with a very little span between Mach 1 and stall speed (minimum flyable indicated air speed), then they are in the Q-corner.
This limits commercial craft to the range of around 40kft altitude.
The way the U2 spy plane can get up to 60kft is by having a much lower stall speed.
It has long, narrow wings like a glider.
Even so, it routinely flies in its Q-corner, and care must be taken in turns, because the "outer wing" may overspeed at the same time as the "inner wing" stalls.