In our area, there's a 5k almost every weekend, usually to benefit one charity or another. Unfortunately, by the time the organizers pay for permits, insurance, and race production costs (road closures, porta-potties, water/gatorade, and chip timing), the charities don't make a whole lot of money.
Our running group does a few free 5k "races" throughout the year, always with some kind of theme to make them more fun than the usual boring run down one of three stretches of pavement that the city allows races to use. We also put on two free half marathons each year with a pot-luck lunch afterward, but you're responsible for providing your own gatorade and energy gels during the race (unless we happen to get a sponsor to pay for those things, which we were lucky enough to do this year). The 5k runs are untimed, and the half marathons are timed by hand, saving a ton of money for the club. We always collect gently used shoes and canned goods for the local shelters and food bank at these events, so there's a charity aspect to it as well. We also sponsor multiple group runs and free cross-training workout each week.
How do we pay for these things? With one paid marathon/half that we put on in the spring. Most of the proceeds go to race swag (custom handmade medals and other goodies) and awesome food for the runners, and the rest is used to cover the costs of our other activities throughout the year. The whole thing is a labor of love, but we do hope to eventually be able to pay our race director a small salary in order to accelerate her husband's FIRE goal...
All that being said, we usually won't pay to run a 5k, but we spend way too much on marathons and half marathons every year. We use the races as an excuse to travel, and it's one of the luxuries we allow ourselves in the budget.