The full quote is as follows:
If you can bear to hear the truth you’ve spoken
Twisted by knaves to make a trap for fools,
Or watch the things you gave your life to, broken,
And stoop and build ’em up with worn-out tools.
In this poem Kipling is describing to his son his version of how a real man behaves. These lines mean that a true man will keep soldiering on and rebuilding, even with inadequate tools, when his truths are twisted by "knaves"—liars with bad intentions—and when people break what he has worked hard to build. Bad things will happen to a man as he goes through his life, but he has to keep on going without complaining, and he must continue to work hard and be a striver.
The lines above repeat the theme of maintaining a stiff upper lip that is reiterated throughout the poem. According to Kipling, a real man keeps on bravely without complaint or showing that he is suffering difficulties, no matter what life throws at him. A real man makes all that he does look easy and never loses his grace or cool.
The poem glorifies what today we might frown on as "toxic masculinity" that stuffs down feelings to keep up a false facade in ways that are emotionally unhealthy and likely to lead to physical health problems. However, it expresses the British national myth about stoically suffering in silence. This ideology gained steam in the latter half of the Victorian era as England consolidated its hold on a vast empire. It was kept up into the early twentieth century. It began to be challenged after World War I as people started to question not talking about the suffering and survivor grief brought on by the high death rates in that conflict.
These lines speak to accepting what happens, and being willing to rebuild when things are torn down, in order to be a man.
When Rudyard Kipling says, "If you can bear to hear the truth you've spoken twisted by knaves to make a trap for fools," he means that sometimes, even when you speak the truth, others will change your words to hurt others or convince others of untrue things. He is saying that you have to be able to live with this: it is inevitable. You have to be able to overcome the negative feelings that might arise from this and move on with your life.
Kipling goes on to say, "Or watch the things you gave your life to, broken, and stoop and build ’em up with worn-out tools," which means that when things fall apart, a man fixes them. He doesn't simply mourn the damage that's been done: he is willing to look at his life's work after it is damaged, accept it, and then move to fix it.
Each of the lines in the poem describes someone who is a man, in Kipling's eyes: someone who is responsible and mature. It's not just about being male; it's about having the persona that comes with being a grown and mature man. When someone can fulfill all the qualities that Kipling has laid out—including the two quoted above—then they are able to claim that they're a man.
The first line is "If you can bear to hear the truth you've spoken/Twisted by knaves to make a trap for fools . . ." As with all the conditionals in the poem, this is designed to be a test of manhood. So if you can handle the fact that speaking the truth will often get you into trouble—because people will distort your words for their own ends—then "you'll be a Man, my son!"
As indeed you will be if you can "watch the things you gave your life to, broken/And stoop and build 'em up with worn-out tools . . ." This is undoubtedly an allusion to what Kipling sees as the thankless task of colonialism, which involves building an entire civilization from scratch but which can all too easily be destroyed by the ungrateful natives. And when that happens, the colonialist must show himself to be a man by building the whole thing up again using the "worn-out tools" or limited means at his disposal.
One of the major themes of this poem is that the superior person, anyone who is fit to be called a "man," is someone who will do their best at all times. They will work hard and never give up, even when they are surrounded by lesser people who do not appreciate their work and who may even destroy it. This is the meaning of the lines you cite.
Kipling is saying that you may do and say great things and other people may distort or destroy them. They might do these things either because they are fools or because they are bad people. Either way, the superior "man" just takes that in stride. The superior man sees his work or his words destroyed and just gets back to work.
So, these lines are saying that you never give up and you never allow other people to affect what you do. If you know you are doing right, you just keep doing it, even if other people are destroying your work and even if you are worn out and tired from your efforts.