I compete for many reasons. For one, I like rising to a challenge and I appreciate that quality in other people. It takes a certain amount of character and courage to do it, kind of like asking a pretty girl out on a date. You're putting yourself out there in some ways and taking a risk. Winning sure feels good, but losing can be heartbreaking and humiliating.
Many matches have per-determined courses of fire or require you to perform certain procedures or do something a certain way. That gives you something by which to measure your skills and progress. You're forced to examine your strengths and weaknesses and to practice things you would otherwise likely not practice if you were just screwing around at the range (mag changes, or shooting a pistol weak hand only, for example). This gives you goals and purpose when you go to the range.
Competing makes you evaluate your equipment and the way you do things. You look for ways to improve and optimize them to work for you so that you can perform at your best and hopefully gain an advantage over your competitors. It's a form of R&D that often leads to new ways of doing things better and more efficiently. A lot of new equipment and techniques have come about from things that were learned in shooting competitions. I generally always learn something of value at a competition.
Many of the skills and knowledge you gain from competing carry over to other activities, like hunting. Shooting under time pressure, at snap targets or at a moving target are things you may never get to practice at a regular range.
Competition is a great way to build camaraderie with the other people who do it.