The International Civil Aviation Organization was formed in 1947 under the auspices of the United Nations, and it established Flight Information Regions (FIRs) for controlling air traffic and making airport identification simple and clear.
Code selections in North America were based on existing radio station identifiers. For example, radio stations in Canada were already starting with "C", so it seemed logical to begin Canadian airport identifiers with a C (Cxxx). The United States had many pre-existing airports with established mnemonic codes. Their ICAO codes were formed simply by prepending a K to the existing codes, as half the radio station identifiers in the US began with K. Most ICAO codes outside the US and Canada have a stronger geographical structure.
Most of the rest of the world was classified in a more planned top-down manner. Thus Uxxx referred to the Soviet Union with the second letter denoting the specific region within it, and so forth. Europe had too many locations for only one starting letter, so it was split into Exxx for northern Europe and Lxxx for southern Europe. The second letter was more specific: EGxx was the United Kingdom (G for Great Britain), EDxx was West Germany (D for Deutschland), ETxx was East Germany (the ETxx code was reassigned to military fields after the reunification), LExx was Spain (E for España), LAxx was Albania, and so on. France was designated LFxx, as the counterpart EFxx was unambiguously northern Finland (originally OFxx, as the more rigid geographical structure evolved over time; in the beginning, countries usually had "blocks" of codes; for example, Finland still has the country identifier OH- in its aircraft registrations).