I enjoy watching motorsport - four wheels, not two. But a lot of the events that I see on TV - Motors TV and ITV 4 mainly - seem to have vanishingly few spectators. Sure there are capacity crowds for the F1 races and the like, but for the others the stadia seem to be pretty empty. So where’s the money coming from?
There is a lot of money tied-up in advertising and sponsorship. And that’s not just based on what a spectator may see when attending the event; most of the $ is associated with the television broadcasting. The various networks will purchase the rights to televise the race so they can insert their sponsors’ ads.
Also a lot of the advertising is from the winners. The tire that won bla bla bla. You’ll those adds are you local car parts store. In some cases the race is just to prove out the equipment.
Formula 1: tracks get subsidies from governments (increasingly despots) on the belief it provides good publicity and money from fans from other countries coming to their country to see the race. The tracks get bled by the people running F1 (Bernie Ecclestone and CVC Capital Partners) charge huge amounts to host a race and take revenue from track advertising plus tv money. All tracks keep is the gate and high ticket prices aren’t enough. NASCAR shares tv revenue with tracks (more than half the tracks are owned by NASCAR’s sister company ISC). But F1 is the most widely watched yearly sports league (olympics and world cup soccer are higher but every four years) so F1 pushes that. Even with declining ratings, sports get good tv money since fans(highly desirable 18-35 year old men) watch them live.
Some tracks have gone out of business because distance from fans in cities means fewer will travel as large screen HD tvs become more widespread. Some well known tracks as Laguna Seca and Lime Rock have problems since as their neighborhoods get more populated and wealthy, they face restrictions on noise (many race fans suffer from the delusion that you are weird if you object to 30 cars each making 115 dbs of noise for two hours.
Lot’s of tracks need a sponsor who pays to have the race named for them. “ACME Company 300 at XYZ track” so they get publicity. In IndyCar that is often the difference as to if a track has
a race or not. Get broadcasters to mention the company name and show it on graphics.
I agree with the answers so far. But another answer to the question posed in the OP is, for many teams, they don’t. Stay in business that is. F1 alone, supposedly the richest form of the sport, is littered with failed teams who collapse leaving mountains of unpaid debt. Of the current crop, only Williams, McLaren, and Ferrari have survived basically unchanged since the 70s. In all cases they have been very successful for extended periods during that time, though I suspect Ferrari would have gone bust in the early 90s had it not been for the support of the road car business (this is not especially surprising - Enzo Ferrari only started making and selling road cars to fund the racing programme). Williams and McLaren have benefited from shrewd and careful management. But like airlines, a lot of teams are heavily loss-making. Many at the back of the grid can only race at all because rich drivers pay them, rather than the other way round (or at least that was certainly the case a few years ago, it may have changed now).
It hasn’t.