Fantasy has a lot of tropes to support it. Most people are familiar with the pseudo Medieval Western Europe setting that is so common.Why, I wonder, are tabletop role-playing games dominated by the fantasy genre or genres close to it (urban fantasy, dark fantasy and science fantasy)?
I don't think it is just because D&D was first. It has been 40 years and we have seen literally thousands of RPGs in all manner of genres, and still fantasy games seem to dominate. Is it that the people drawn to TTRPGs have an inherent interest in fantasy (more than, say, hard sci fi or westerns)? Is it that fantasy is somehow easier to play than other genres?
The modern era is familiar, but there are fewer tropes to support it. Sci-fi is unfamiliar, and also has fewer tropes to support it.
I could start a game with "you all meet in an inn" in D&D and be confident the PCs will befriend each other, work together, and go on adventures. (I always do session zero, but when I was younger, we did the meet in an inn thing.) If I try that in modern or sci-fi, it will likely crash and burn. Characters are constrained by the setting of fantasy, whereas it tends to be constrained only by the GM for other settings. Many players can handle fantasy, but not modern or sci-fi.