Airlines pay a fee to fly over other countries. They're called overflight fees. Just as countries have rights to their land, they have rights to the air above them. Most countries rent that airspace to foreign airlines, allowing them to fly through it.