The "speaker" in the poem - the person saying the words of the poem - is a father talking to his son. Using the pronoun "you" gives the effect of making this very clearly a conversation, or perhaps a set of behavioral guidelines or instructions being passed from father to son. The father is speaking very directly to the boy as he provides examples of what to do and what not to do, how to act and how to not react in a whole series of different situations.
If you can keep your head when all about you
Are losing theirs and blaming it on you
The goal of his advice is to help his son understand the type of conduct and behavior that the father hopes the son will display as a mature and responsible adult in every sense of the word.
Yours is the Earth and everything that's in it,
And---which is more---you'll be a Man, my son!