Rudyard Kipling, whose father was a Freemason, became a Freemason and Lodge Secretary in Punjab, India. Freemasonry very much affected Kipling, as he valued its "idea of secret bond, of a sense of community, and of high principles" ("Rudyard Kipling and His Masonic Career," Pietre Stones Review of Freemasonry). Within Freemasonry, social class and caste systems do not exist, an idea that deeply moved Kipling. Therefore, principles of Freemasonry are often themes in his works. Kipling opens his novella "The Man Who Would Be King" with the statement, "Brother to a prince and fellow to a beggar if he be found worthy," which alludes to Masonic principles.
The statement, or "Law," as Kipling's narrator calls it, reflects Masonic principles by speaking of treating those who are highest above you, such as princes, as brothers and those who are the greatest in need, such as beggars, as your fellows or companions so long as the beggars are virtuous. In referencing the two greatest extremes of the social class system—the prince being a member of the highest class, whereas the beggar is a member of the lowest class—Kipling is referencing the Masonic disbelief in class distinctions.
In his opening paragraph, Kipling further asserts that the "Law" he opens with is not easy to follow. He has not yet been able to follow it because he never had the opportunity to "be brother to a Prince," and, though he has been "fellow to a beggar" multiple times, he has never been able to find out if the beggar was really worthy of fellowship. He goes on to recount the story of his encounter with two fellow Freemasons who were vagabonds, Daniel Dravot and Peachy Carnehan. Through the encounter with Dravot and Carnehan, Kipling weaves Masonic and anti-imperialistic themes together.
Kipling uses the story of Dravot and Carnegan to question their worthiness as Freemasons because they tricked Afghanistan natives, who practiced Freemasonry, into believing Dravot was the "Grand-Master of all Freemasonry in Kafiristan" and to set Dravot up as reigning equally with Carnehan as King of Kafiristan. By doing these things, they broke the principles of Freemasonry because they lied and declared themselves to be above others. In addition, as imperialists, they took advantage of the natives' so-called "lesser intelligence," but, by the end of the story, they received their just desserts. Kipling uses the story of breaking Masonic codes of behavior by treating colonists as subordinates to show the wrongfulness of imperialism.