One theory is that Kipling wrote the poem "If—" in honor of Dr Leander Starr Jameson, a British administrator of Rhodesia (now Zimbabwe) in South Africa. In 1895, Jameson, with close to 500 men behind him, led a march on Johannesburg to overthrow the Boer government and so create a British federation across South Africa. Jameson was told by the British High Commissioner not to go ahead with the march, but he ignored the instruction and pressed ahead regardless. The attempted coup failed, and Jameson was arrested and sent back to England to serve a fifteen month prison sentence.
Kipling was an avid proponent of British colonialism and believed that the white Europeans had a duty to civilize what he called, in "The White Man's Burden" (1899), the "sullen peoples" of Africa, who he also, in the same poem, called "half devil and half child." Kipling, therefore, admired Jameson's efforts on behalf of British colonialism, and "If—" can be read as a tribute to Jameson.
Another theory is that Kipling wrote the poem as a form of fatherly advice for his son, John, who, in 1910 when "If—" was written, would have been thirteen years old. The poem is full of advice that might be appropriate for a boy entering the adolescent stage of his life, and the final line ("And—which is more—you'll be a Man, my son!") is certainly fitting if written for an adolescent boy.