The object of a referee in any sport is to make sure a game is played fairly, safely and within the rules. That's it.
Sports can exist without referees. Players have been calling their own fouls on the playground for years. But things are different in organized sports. There are stakes—a reason to win other than simple schoolyard pride—and the higher the stakes, the better the chance someone might break the rules in order to win.
The bigger the stage, the more important the referees become.
A few weeks ago in a recreation soccer game between a bunch of six-year-olds, the referee—a monetarily compensated high school student—didn't call an obvious handball.