It's about the qualities which are virtuous and desirable in a man at the time of writing (or, at least, what Kipling considers to be desirable qualities). It's about human behaviour and arguably a reflection on society at the time. The purpose is debatable - it suggests behaviour to be a mature, respectable individual, so in that sense its purpose is to advise, but its being a poem also suggests that it is there for entertainment and philosophical contemplation as a (moral) outlook.
The poem uses a lot of parallels and comparison between 'you' and the rest of the men of the world ('keep your head' when everyone else is 'losing theirs'; 'trust yourself when all men doubt you'). Metaphors are also used frequently, and to great effect ('walk with kings' probably doesn't refer to actual royalty, simply people of higher class; 'fill the unforgiving minute with sixty seconds' worth of distance run' is, likewise, not literal - you don't have to be running, just achieving something and using your time wisely; 'make a heap of all your winnings' is not suggesting you actually put all your possessions on the table in a casino, just advising that you accept that material possessions are not everything and you are bravely and wise enough to acknowledge that sometimes a gamble will pay off).