“The Man Who Would Be King” is technically set in India, where the narrator first meets Carnehan and Dravot and where Carnehan later shares his lengthy story about his time in Kafiristan with Dravot. Because Carnehan’s story takes up the bulk of the narrative, Kafiristan can also be considered one of the settings of the story.
It is important to note that Kafiristan is a region of present-day Afghanistan but, at the time Kipling published the story (1888), it was mostly unknown to Westerners. In this way, Kafiristan as a location is somewhat arbitrary—it was a place outside of India that, Kipling knew, had a majority Hindu population, so would work as a parallel to India in this allegory for British colonialism.
Kipling spent part of both his youth and adulthood in India and pulled from those experiences when choosing to set the story there. As a white British man in colonial India, he was raised to view native Indians as inferior and in need of civilizing. This is an ideology that he brings to “The Man Who Would Be King.” While it may seem like he is mocking European colonizers in the story, he is mocking a particular form of European colonizer—those who he viewed as ignorant and immoral.
Overall, Kipling still perpetuates racist, outdated views in this story, specifically that colonized subjects were inferior and in need of outside support, as evidenced in the ways he depicts the Kafir characters as bloodthirsty, unintelligent, and superstitious. This is in no way an accurate depiction of Afghani people.