When I finished playing bball, I had no interest in coaching however, I dabbled in refereeing recreation leagues. I had no clue how really hard it was. Without the advantage of a good clinic, I was doomed. But I was so bad that my whistle and my mind were on different time zones. It's amazing how well they do percentage wise. Every ref makes a tough call now and then but percentage wise - they are really good. I have a lot of respect for both Coaches and Referees. Good or bad they have a very tough job.
My buddy has been a HS ref for decades, did some college along the way. Early in his career (after some experience and clinic training) a ref allied in sick for a varsity game, he was asked if he wanted to sub, which would be his first varsity game. He said sure, asked the other ref if he had any advice. " let them play, get a game flow going". At some point there's going to be a foul, and what we whistle draws the line. If stupid stuff is going on, whistle it, but, for the most part, let them play, keep them within parameters.
Now, years later, he said the refs are responsible for keeping peace and control in the gym. One game there was a home crowd that was out of control, refs call a time out, asked a cop on duty to calm the fans down. He went up there and became part of the action. They called time out (again), told the AD if he didn't reel in the crowd, they (the refs) are leaving, and the AD would have to their report to the county/state sports commission.
Not an easy job, certainly helps if you have some skills, and can be fortunate to have a good mentor when starting out.