It's a way of carrying on the family name, a sort of immortality, if you will.
Of course, sometimes it can go too far. There are people out there with names like Loudon Wainwright III, because he is the third generation to be named Loudon Wainwright. And if he names his son Loudon Wainwright also, then the son will be Loudon Wainwright IV, because English vocabulary doesn't have a word for familial relationships that goes beyond two generations (senior and junior). So we have to start using numerals, and it's traditionally Roman numerals rather than Arabic. I don't know why that last is the tradition, though.
This tradition also only applies to male offspring. If a woman has the same name as her mother, there is no generational term to differentiate the two individuals.
This was also true in parts of Europe. European surnames came originally from sources such as the individual's occupation: Cartwright, Fletcher, Cooper, Taylor, Fisher, etc.; or from location, or sometimes just from some feature identified to differentiate between two unrelated individuals with the same given name. If one John had brown hair and the other was blond, the brown-haired person might be called John Brown just to indicate which John you were talking about. Eventually these "nicknames" became surnames.