tl;dr, English just borrowed other languages' suffixes
I shouldn't really come as too much of a surprise to know that the irregularity comes from borrowing endings from multiple different languages at different times. From this article on linglish.net, these are the origins of the primary suffixes.
||Latin → Italian
||Latin → Germanic
||Latin → Germanic
Note that this list is not exhaustive. Further, the word used for the people are not always the same as the generic adjective form of their nations' name. (ex. "Swedish" but the people are "Swedes", "Spanish" but the people are "Spaniards").
Further complications are that some names of countries are formed from the names of their people or culture, not the other way around. For example, "Germany" comes from "Germania", Latin for "land of the Germans", and similarly "Turkey" from "Turcia", Latin for "land of the Turks".
This is also usually the case for countries ending in "land", ex. "Thailand" from "Thai", though as noted below not all countries ending in "land" are formed this way.
For the curious, you can find a large list of suffixes used on counties on the Wikipedia page for Demonym. Another list can be found on the very descriptively titled List of adjectival and demonymic forms of place names. Demonyms are names for groups of people (from the same root as "demographic").
Below are some more details on etymology and why certain countries use a particular suffix; I have quoted the relevant sections of the linglish page.
-ian / -ean / -an
It should not be surprising to find out that -ian, -an and -ean actually have a common origin. In fact, the suffix -ia is frequently used in Latin to name places, thus giving birth to names like Romania, Bulgaria and Australia, and -ea and -a are two other grammatical suffixes used on Latin nouns. The final -n is an adjectival suffix that turns a noun into an adjective. Hence, adjectives that end in -ian, -ean, or -an were either borrowed directly from Latin, or modelled after Latin in English.
In Italian, -ese is a much more common suffix of nationality than in English. [...] In fact, -ese (from Latin -ēnsis) is the next most common suffix after the Latin triplet -ian/-ean/-an.
It turns out that words ending in -ese in English actually come from Italian. Recalling that Marco Polo and other Italian traders were the first Europeans to reach the Far East, it is therefore no surprise that many Asian countries use -ese. In addition, the countries using -ese in South America are all very close to where Christopher Columbus, himself an Italian, first landed on the continent. But of course, why some countries in Africa and the Americas use the Italian suffix, while others use French or Spanish suffixes is a result of their long and complicated colonial histories.
-er / -ic
Both -er and -ic are originally Latin suffixes which later entered the Germanic languages and subsequently English. Among the two hundred countries in the world, -er and -ic are used only after the words land and island, both of which are Germanic in origin. The suffix -er is used on nouns to denote persons of a certain place of origin, while -ic is used to form adjectives with the meaning of “having some characteristics of”. Therefore, Icelander is normally used to denote a person from Iceland (i.e. a noun), whereas Icelandic is used when it is used as an adjective.
This is a native Germanic suffix with the sense of “belonging to”. Since English has been much influenced by French and Latin, the suffix is not as productive as it used to be.
The suffix -i, with the meaning of “belonging to”, comes from Arabic. This explains why almost all countries that use -i are Islamic and/or use Arabic as one of the major languages.