The mostly is significant; in several cases the ISO was over-ridden and arbitrary but sensible codes assigned e.g. UK instead of GB. Many smaller territories were not granted codes in ISO3166 and had to be 'invented' for the TLDs
ISO3166 is in itself a bit of a mess, and since it became used for TLDs there have been dozens of requests for changes and additions based on new TLD assignments.