Discussions of diversity in fantasy (and fiction in general) generally talk about the moral and social importance of showing positive diversity, in particular the need for positive role-models for members of under-represented races, genders and orientations. All that's vitally important, but there are two other reasons why it's important. Lack of diversity is unrealistic. Lack of diversity is boring.
Of course, I'm certainly not suggesting that every story has to have a "diversity quota", especially not short stories. If you were write a story set in the World War One trenches, for instance, your cast would have to be predominantly male and probably mostly white (though any opportunities for more diversity would be welcome) and there are even situations in secondary worlds where this makes sense. I've written stories with all-male casts, but then again I've also written stories with all-female casts. When the cast might be only two or three people, it has to meet a specific need.
Diversity is best measured over an author's opus, or even over a widespread trend. It doesn't matter if I write one story focusing on white males, if I write others where black females come to the fore.
In fantasy, it can also be measured by how the world is presented, and this is really where the unrealistic and boring issues come in. SFF is good enough at portraying a variety of exotic races, though even these tend to be cut and dried. Elves are all snooty tree-huggers, dwarves are all gruff axe-wielders, Klingons are all obsessed with their honour… and so on.
In SF, if a human protagonist visits a planet, they're likely to find an alien race who are all alike, all following a single culture and religion wherever they are on the planet. Assuming there is anywhere else on the planet. "A planet", especially in film or television SF, often seems to consist of one city, or a small group of villages, and nothing else, just like a fantasy "world" is often only a handful of kingdoms surrounded by terra incognita.
Increasingly, though, fantasy is focusing on secondary worlds populated by humans. And, more often than not, the story will be about countries populated by European-type peoples, and most of the active characters will be male.
The justification often given for the latter bias is that historical cultures in our world were always strongly patriarchal, so it would be unrealistic to show strong females. In fact, by no means all cultures were patriarchal. When the Kingdom of Sheba (or Saba) in Yemen was excavated and inscriptions giving the names of rulers were found, even the sober archaeologists were understandably excited about identifying the "Queen of Sheba" from the Bible. In fact, they discovered that nearly half of Sheba's rulers were female. It wasn't a matriarchy — it was just that the Shebans didn't seem to have a strong preference about the gender of their ruler.
In any case, a secondary world doesn't have to slavishly follow the same lines as our world. As long as there's a good internal logic, you can have whatever kind of society you want, including sexual equality. Invoking history is just an excuse.
The same is true for the distribution of race in a secondary world. Of course, to a large extent races with lighter skins will tend to live in cooler climates and those with darker skins in the hotter regions, but this doesn't mean they'll necessarily have the same cultures as their real-world equivalents.
In my main world, I have white, black, yellow, red and tan races (plus an isolated race with a green tinge) in a roughly similar distribution as in our world (except for the green race, that is) but the balance is very different. As in our world, civilisation began independently in several zones, but here there was no global takeover by any one of the zones. The predominantly black continent, for instance, not only had ancient, high-achieving civilisations (as Africa did) but, in the "modern" era, these civilisations still operate on a roughly equal level with those on the other continents.
Now, some might say that, in portraying black races who don't have the legacy of the slave trade and colonial exploitation, I'm belittling that heritage. My view is the exact opposite. It seems to me that, if I were to portray another, unrelated world whose black races have suffered slavery en masse, I'd be coming perilously close to suggesting that was some kind of natural destiny for black people. Obviously it's not. In our world, it was something done to Africa as a result of a specific lining up of global factors, and there's no reason to assume this would happen in a different world.
Nevertheless, without racial diversity, it's difficult to portray a range of cultures and show a truly varied world — and it's not only necessary to have the races, but to use them on an equal basis. Most traditional fantasy has European-style main characters, with other races as "exotic" or "barbarous". This isn't necessarily a sign of active racism. Tolkien, for instance, was fairly anti-racist for his generation and class*, but he still fell into the cultural trap of portraying only undifferentiated hordes of his darker-skinned humans.
I try to write stories with main characters of as many of my world's races and cultures as possible. One of my most recurring characters, Eltava, would in real-world equivalent be a cross between Chinese and Native American, and several of my stories have central characters who are black. For example, in my recent Musa ebook, The Lone and Level Sands, three of the six significant characters are black (and one other is most closely equivalent to North African) and the archaeological expedition central to the story has come from a university in a country with a black population.
Still, I haven't always got it right. My world and many of my characters have been evolving for several decades, going back to a time when I didn't have so much awareness of the need for diversity. The result is that I still have a disproportionate majority of white characters and cultures focused on, although I hope that will gradually diminish.
Ultimately, though, as I said at the beginning, getting diversity into fantasy isn't simply a moral duty. It's a way to make your world zing. It's a way to create conflicts and relationships that come from genuine difference, and to explore a reality as complex and fascinating as our own.
And to pass that on to your readers. After all, who really wants to read about a world without variety?