Why fantasy?
1. Because D&D is fantasy, and D&D is the predominant game in the hobby.
2. Because fantasy, moreso than any other genre, particularly lends itself to both the "campaign" and to the reward play loop (zero-to-hero) that so many people enjoy. In addition, while other genres have examples of group play (Science Fiction has Star Trek and the bridge crew, while Super Heroes has, inter alia, the Avengers or Guardians of the Galaxy), few genres have such a well-entrenched (and copied) example like the Fellowship.
3. Because it's fantasy, and actually realistic medievalism. So, one thing most people agree on is that fantasy, generally, tends to be a
reactionary and
small-c conservative genre. It is the imagining of some bygone time (that never existed). It often involves battles between identifiable forces of good and evil. There is usually the presence of various governments that are autocracies, and the main concern with the autocracies are whether they are good (kind, benevolent, for the people) or evil (bad, tyrannical, expansionist) as opposed to an in-depth look at the nature of autocracy. It is exceedingly common for power or importance or skill or magic to be the result of bloodlines- it might be hidden (Harry Potter, Luke Skywalker, etc. etc.) or might be overt (Strider/Aragorn). Even the subversion of the tropes often reifies it (GoT and Jon Snow). None of this is, or should be remarkable.
What is surprising is the extent to which some people assert that D&D necessarily resembles medieval Europe- or would have feudalism. To start with, D&D is fantasy, but while it borrows tropes from European (and other) fantasy stories, it doesn't resemble any specific historic period so much as it resembles ... itself. Arguably, D&D incorporates has, from the beginning through 5e, incorporated elements from 2800 B.C. (Middle Kingdom of Egypt) through the Roman Period (~100 BC on) continuing on to King Arthur (eh ... invented later, but backdated to the 6th century AD) on to the Medieval period and then through the Renaissance and incorporating, arguably, elements right up to the industrial revolution (we will say 1760). ....
and that's assuming you're not running Eberron or some other similar campaign.
4. Because fantasy worlds have autocracies (usually monarchies) that we can use without worrying about it too much.
And I think this gets to the heart of why monarchies and autocracies are so common in RPG
games. The emphasis is on the game, on the conflict. And conflicts and stories work best with identifiable personalities.
Generally, people want to interact with a single point of contact- and rulers ... whether they are kings or queens, autocrats or generals ... they allow streamlined play and roleplay. They make the game easier to run, and for many tables, more fun to play. It's not just a trope of fantasy- it's a crutch of a lot of storytelling. It's easier to play when you're dealing with a small group of people or leaders, than it is with a sprawling democratic system.
5. Finally?
Magic. People dig magic.