Three-letter codesare IATA location identifiers, or station codes, defined by International Air Transport Association. They are assigned to many airports around the world and published in the IATA Airline Coding Directory twice a year - in June and December. Nowadays, the three-letter coding system is an essential part of the air travel industry as it secures efficient work of airline schedules, flight reservations and baggage transportation. In general, smooth air travel much depends on the three letter codes.
The three-letter coding dates back to the 1930s - the time when airports started to spread around the world. Before that, certain cities and areas in the US had already been assigned a two-letter code by the National Weather Service. The first airlines had used those codes before an increased popularity of air transportation caused more and more airports being built. The solution was found in the three-letter coding system with over 17,000 combinations.
The existing airports, like in Portland or Los Angeles, were just added the letter 'X' to the previously assigned weather station code (correspondingly, PDX and LAX). Many others just employ the first three letters of the city name (DEN for Denver International, GLA for Glasgow International). It can also be the first letter of each word in the city name (SLC for Salt Lake City, POS for Port of Spain); or any three letters from the city name (e.g. BLI for Bellingham, GTY for Gettysburg).
Sometimes the name of the airport is encoded in the acronym, thus making it more "tricky" to decipher. LHR stands for London Heathrow, and the main airport in Paris is called Charles De Gaulle, or CDG.
A few letters are saved for special purposes. Since "N" is reserved for military, Newark and Norfolk put up with EWR and ORF, correspondingly. Key West turned into EYW, Wilmington - into ILM, as K and W are designated for radio stations. Y is set aside for Canada, so YQB stands for Quebec and YUL for Montreal.
Occasionally, you need to look into history to understand the origin of the airport code. Thus, Kahului airport in Maui turned into OGG thanks to Capt. Bertram J. Hogg, and the code GEG is used for Spokane International in honor of Major Harold C.Geiger.