Because someone's closed a bunch of roads :)
Seriously though: You can sell tickets at the starting and finishing lines, or by putting a loop in the course and sending the riders past the spectators 10 times.
But for the rest of the course, the riders will shoot past in a few seconds.
Look at this density of spectators: https://youtu.be/2ytb_ajLCFw?t=160
You can't sell a 'party atmosphere' or pad the entertainment out with dancers and marching bands and food trucks because the spectators are spread out over the entire course.
And even if you decided to charge for tickets despite that - the course isn't fenced off, so people without tickets can just walk in. And if you added fences and bouncers checking tickets, you'd need loads of them because the course is far too long to funnel everyone through a single entrance like a music festival does. And even if the fences and bouncers somehow made economic sense, you've gone from blocking a section of road for an hour as the race goes past to blocking it for a day or two as the fences get built.
On flat terrain in the middle of a stage you might be able to just park up and wait for 30 minutes but you’d also be missing the spectacle surrounding the race itself.
No one goes to the Kentuky Derby to watch the horses run for 90 seconds - that's much better done on TV.
So... it's a spectator sport?
Its 3 hours of 'prep' because the courses are usually way out there, way far away from anything, and near the route traffic is upside down, maybe there is parking maybe there is none, nobody knows.
It doesn't happen at a 'venue' that's designed for sport, it happens out there in the French boondocks.
So you make a day of it ie sightseeing.
It's an excuse to get out and see the country.
Such climbs often are over the only decent roads up the mountain, and those roads will be closed down an hour or so before the riders arrive.
There also will be competition for the best spots (in the outside of corners, where you can overlook the road)
Because of that, for many, it’s easily 3 hours of (traffic and waiting), even ignoring traffic time. But that need not be bad. You bring food and drink, sit in nice weather (hopefully), and watch the stage on tv.
If it isn't a spectator sport... why do you have to wait in traffic to get to it?
Seems like a 'nobody goes there it's too busy' sort of argument?