The above is a good introduction to *how* the system is used (and further information on that is readily available by either searching this site or googling), but the sense I get is the OP is also curious as to the *why*.
The handicap system is simply a way of leveling the playing field for golfers are differing ability, with the goal being for the winner to be whoever played closer to their own personal potential.
A lot of folks (myself being one) don't like the idea of using handicaps in tournaments, because we don't like the idea of someone being called the "winner" even though they had a worse score than other competitors. And although the system has been refined over the years and is probably as good as it's going to get, it's still not perfect. (It fails when someone is able to manipulate their handicap through what's known as "sandbagging" such that it's higher than it should be.)
But as I say, it's a great system for allowing people to compete and be rewarded based on how well they played compared to their own theoretical potential, vs. how well the rest of the field played to their potential.
For me, the biggest benefit of the handicap system is the ability to use it when I'm playing with friends. It makes it possible for anyone to win (if they play well), which would not otherwise be possible when the skill levels of the guys I'm playing with vary widely.
The racing analogy is a good one. I've participated in and helped define rules for time trial series where you get a certain amount of seconds added to or subtracted from your raw times based on things like horsepower/weight ratio and modifications to the cars. While you still want to group similar cars together (as is done in handicap "flights" in golf tournaments, where golfers with handicaps in a certain ranges only compete against others in the same range), such a handicap system allows different makes and models of cars with varying degrees of modifications to compete more fairly against each other. (At least in the sense that driver skill is rewarded more than how good your car is.)