It doesn't (much). I say "much" because there are some thermodynamic efficiencies of an internal combustion engine that make the following explanation not 100% true, but those effects are an order of magnitude lower on the influence scale.
In general, there are three major forces that a moving vehicle's engine are working against: rolling resistance of the tires, aerodynamic drag, and forces due to acceleration (F=ma). Ignoring the aforementioned thermodynamic efficiencies, you calculate horsepower eaten up by each of these forces by multiplying vehicle speed times force.
In all cases, the power output of the engine must equal the total of those forces to maintain that speed and rate of acceleration. Since time is a factor on both sides of the equation (power from the forces on the vehicle on one side and engine output horsepower on the other), it cancels out. And since power is energy expended per unit of time, that leaves an energy balance equation. The energy from the engine equals the energy required to overcome those three forces.
Again, ignoring the thermodynamic efficiencies of the engine, the energy output by the engine is pretty close to directly related to the volume of fuel burned. Further, since the PCM ratios the amount of fuel spit out by the injectors based on the intake air density, if you take identical conditions, but one is at sea level and the other is at 5000', with the lower air density at 5000', the only way to maintain the energy balance is to apply skinny pedal - increase the load on the engine and burn more fuel to get the energy required. In both cases, the energy required is the same, so the amount of fuel required is the same. You're just using different throttle positions to deliver that same amount of energy from the engine.
Stated another way, let's say you are driving your TJ at 5000' on a level road at 60mph in Colorado today. Two days later, you're at the gulf coast driving your TJ at 0' on a level road at 60mph. In Colorado, your throttle position is higher than it is on the coast. So, your first reaction would be to say, "well, I must be burning more gas and my fuel mileage is lower." However, that's not the case. You have to depress the throttle to apply a load on the engine to make it output the same power to make up for the lower air density. You're burning fuel at the same rate in both cases. However, the throttle position required is different.
Hopefully this makes sense the way I've described it. Of course, this is an over-simplification of what's involved in vehicle power calculations, but adding in all the other factors has only a small effect on the results.