"If" is advice being given to a son by his father. The father is suggesting to his son ways of living and relating to others that will allow the son to grow up into a good and respected man.
The advice is given through a series of contrasts, suggesting a poor way of reacting to a situation and then giving a better method. "If you can keep your head when all about you are loosing theirs and blaming it on you" - the father is urging the son to not let himself get upset and anxious, even if others are doing so, and especially to not let himself become distracted if the others blame him for the problem.
The poem continues in this basic pattern. The son is encouraged to press on toward what he knows is right and worthy of achieving, without complaint if things go wrong, without attempting to shift blame to others, without allowing himself to be distracted by actions or reactions of those around him.
If you can force your heart and nerve and sinew
To serve your turn long after they are gone,
And so hold on when there is nothing in you
Except the Will which says to them: "Hold on!"
The father concludes by telling his son that if he succeeds in following these suggestions, he will grow up to become master of "the Earth and everything that's in it" and, best of all, will achieve true and full mature status - "you'll be a Man, my son!"