Why is gas mileage typically better when traveling on the highway than on country roads or in the city? The gas mileage of my vehicle tends to improve the more I have been driving on the interstate on that tank of gas - if I go through a tank of gas without at any point driving on the interstate, I will typically get 24-26 MPG, but when I have driven almost exclusively on the interstate, I will typically get 26-29 MPG. 
What confuses me is that, when traveling on the interstate, I am driving great distances at higher RPMs, which I would expect to correlate to more gas usage and thus worse gas mileage. Why does the inverse seem to be true?
 A: It is all about engine operating regime and how much braking and re-starting you do


*

*The efficiency of internal combustion engines varies enormously over their range of safe operating conditions. In miles per gallon terms, of course, idling at rest is as bad as it could possible get. Manufactures take some trouble (in designing the whole powertrain) to ensure that the engine runs in relatively an efficient regime at highway speeds.

*Accelerating the car takes more energy than just tooling along at a steady speed (that extra kinetic energy has to come from the fuel after all), but when you brake that energy is not recovered---it is converted to heat. So city driving with it's stops and starts means that you keep pouring energy into kinetic form and then promptly converting it to heat so that you have to go get some more from the fuel tank. Over and over again. That can't be good.


Try it with an electric or a good hybrid and your mileage will go down on the highway because it is dominated by air resistance.
A: Gear ratios also play a role in the mileage. Typically, your gear ratios would be something like
$$
\begin{array}{c|c}\rm gear & \rm ratio \\ 1st & 3:1 \\ 2nd & 2:1 \\ 3rd & 1.5:1 \\4th & 1:1 \\ 5th & 0.75:1\end{array}
$$
As your gear increases, which happens on interstates because you're traveling faster, it takes fewer rotations of your engine to turn your transmission (and thus wheels). At lower gears, i.e. city driving, your engine does quite a bit of work to turn the transmission.
A: Dmckee is right, but I feel like I should emphasis this further: The constant stop/go traffic of city driving is brutal on fuel economy.
Gas/Diesel vehicles can't recuperate energy wasted when braking, unlike hybrids and electric vehicles (regenerative braking is one of their main advantages). You're constantly burning gas to accelerate, then wasting that energy as brake heat.
A: This is more an automotive engineering question than a pure physics question. Different cars can have very different results.
By "driving on the interstate" you mean driving at relatively constant high speeds. On country roads, you have to brake a lot, and in the city, you're both braking and sitting at intersections with the engine running. Factors like speed and braking matter more than engine RPM's, unless you have a manual transmission and are purposely staying at high RPM's unnecessarily.
In fact, if your country road was long and straight and had no traffic, that would be the ideal for most cars. In general, a gasoline-powered passenger car gets its best fuel economy when driven at a constant moderate speed (perhaps 30-40 miles per hour) on a straight, flat road. You can think of that situation as the vehicle's peak mileage potential, then consider how various driving patterns decrease the efficiency.
Driving fast on the interstate loses efficiency mostly due to aerodynamic drag. My old CRX has good aerodynamics, but at really high speeds it doesn't matter: it gets 50 MPG at 70 MPH, but less than 30MPG at 95 MPH. Air drag dominates at those speeds.
Braking in a gasoline-powered car converts kinetic energy into heat. It's an amazingly good way of reducing efficiency. Think how hard and how long you have to press the gas pedal to get from 0-60, and how little braking it takes to go from 60-0. Many (most?) cars can decelerate from 60-0 faster than they can accelerate from 0-60 at maximum power. Every time you brake, you are throwing away hard-won kinetic energy. Country roads with corners and hills require braking, and city driving requires a lot of braking. Standing at stoplights is worst of all. Braking and stopping inefficiencies turn out to be even more important than high-speed aerodynamic losses if you have a typical vehicle.
Some hybrid vehicles invert this relationship. Regenerative braking converts a lot of kinetic energy into stored electrical energy. Hybrids also generally shut the engine off when the car is stopped. I recently drove a RAV4 hybrid (relatively poor aerodynamics and an effective hybrid system) that gets 33 MPG in the city, 31 on the highway.
I've also driven an old Honda CR-V that seems to get 24 MPG no matter what. City, country, freeway, stop-and-go, it doesn't matter. Always 24 MPG. I believe this is because its aerodynamics are so poor that it doesn't get the usual advantage that comes from constant high-speed driving.
To really understand how a vehicle responds to different driving conditions, find someone with a recent model that displays instantaneous MPG figures and ask to drive them around for an hour. I drove an Accord that showed an enormous amount of fuel being wasted to keep the engine running at stoplights. And I drove an Outback that shows over 100MPG when going downhill -- it turns out that most modern cars shut off the fuel flow almost entirely when engine power isn't needed.
To reiterate: different vehicles have dramatically different characteristics. But typically, your mileage is better on the highway than the city because braking losses waste more than aerodynamic losses.
A: Car engines don't have constant power output as a function of RPM. My car's manual states that the optimal power per fuel consumption of the engine is at ~3000 RPM, which corresponds roughly to 120 km/h on fifth gear. Apparently, the engines are made so that this is true for highway trips. Of course, such trips don't entail lots of acceleration and deceleration, which wastes a lot of energy.
Check this link for details.
A: Valve timing is a major source of variation in engine efficiency. The internal combustion engine has maximum efficiency at a certain fuel to air ratio. To achieve this, valve timing is set by the engine manufacturer, assuming a certain, commonly used engine rpm (revolutions per minute), which is generally set at about highway driving conditions.
A spark ignition type internal combustion engine generates power by the following steps (there is a graphic below):
With the inlet valves open, piston moves down to bottom dead centre (maximum internal volume), pulling in air and fuel.
Inlet valves close, piston moves to top dead centre (minimum volume), air fuel mixture is compressed.
As cylinder approaches top dead centre, the spark plug ignites the air-fuel mixture.
After top dead centre, the cylinder is pushed downwards (fuel-air mixture combustion).
The cylinder moves to bottom dead centre.
The exhaust valves open.
The cylinder moves to top dead centre, pushing the exhaust gases out. It turns out that efficiency can generally be increased by opening the inlet valves while the exhaust valves are still open, whereby the incoming fresh (air-fuel) mixture helps remove exhaust gases from the cylinder. This is called ‘scavenging’ in automotive terminology.
The exhaust valves close.
The cylinder again moves to bottom dead centre, repeating the cycle.
We know that engine rpm varies with car speed and selected gear ratio. It so happens that for a certain valve timing, the air-fuel ratio in the engine will vary with rpm. This is because, as rpm increases, the momentum of the incoming air (and with it the fuel introduced along the way) increases. As this incoming mixture momentum increases, more air is able to make it into the engine before the inlet valves close. Here lies the crux.
If the engine is functioning significantly lower than the design rpm, then the incoming mixture momentum is so low that it does not contribute enough to the removal of exhaust gases, so that some exhaust gases will still be present in the cylinder when the exhaust valves close (incomplete scavenging). We will therefore have ‘double combustion’ or these unexpelled gases. This is no different from the engine functioning as a compressor for these unexpelled gases, in addition to the fact that the air-fuel ratio will not be ideal for the following combustion cycle. Both of these realities contribute to inefficiency.
If, on the other hand the engine is functioning significantly higher than the design rpm, then the incoming mixture momentum is so high that it does more than to remove exhaust gases: some of the incoming fresh mixture itself is immediately expelled from the cylinder via the exhaust valves (excessive scavenging), never to be combusted: clearly a source of fuel inefficiency.
Variable valve-timing technology goes some way to reducing the problems of under- and over- scavenging.

(source of graphic is http://www.engineeringenotes.com/mechanical-engineering/ic-engine/ic-engine-classification-and-components-mechanical-engineering/35919)
