"The White Man's Burden" is a poem written by Rudyard Kipling. It was first published in 1899 and was inspired by the Phillippine-American War, which took place from 1899–1902. The statement in the question is correct: Kipling does indeed portray "the white man's burden" as a thankless undertaking, so it might definitely feel odd that he urges to reader to continue to take it up regardless. In order to help you understand why he does this, is is first of all important for me to explain the social background within which this poem was written.
The poem is a typical example of colonial writing. White people at this time felt that they were superior to the people of the countries they conquered, particularly when they conquered and colonialized countries where the inhabitants were not white and had not yet found Christianity. People at the time felt that it was their duty to bring civilization and culture to those whom they perceived to be uncivilized. This is what Kipling refers to as the "white man's burden" in the poem: the perceived need to bring education and civilization to the indigenous people of the colonies.
However, as he tells us in this poem, this attempt at Westernizing the native people was not always met with welcome and could sometimes even lead to hardship for the white men, who were trying to change the lives of the natives according to Western standards. However, as people at the time ultimately believed that it was their responsibility to bring Western and Christian values to those who had not yet experienced these, they thought that they were ultimately following God's will in trying to help the natives to follow a Christian and civilized life.
Therefore, Kipling and his fellow people felt that it was not an option to stop doing it. They were so convinced that they were doing the right thing and felt that not doing it would be tantamount to sin and might even lead to God's wrath later on. This is why, despite the hardship, Kipling urges the white man in his poem to keep on going with his task of bringing Western culture and Christianity to the native people in the colonies.