Modern day Tour de France consists of 21 stages. But it doesn't mean, that riders have to ride 21 consecutive days. A Tour de France is held over a time period of 23-24 days. Thus the riders have two (sometimes three)
rest days.
Usually, a Tour de France starts on a Saturday, In rare cases, when the Grand Depart takes place abroad, especially in a bit more distanced country, the race might start on Friday. In this case, as it happened in 2022 in Denmark, after the first three stages there is a restday to transport the entire peloton to France.
Otherwise after the first weekend riders spend the entire subsequent days in the saddle, qnd only after the second weekend, after nine consecutive competing days is a rest day. And the second rest day comes a week later, usually on a Monday, again.
This is currently the basic structure of all the three grand tours (besides Tour de France, also Giro d'Italia and Vuelta a Espana)
There is a good reason I emphasized at the beginning of my post that this is about modern day Tour de France. Back in the heydays of Tour de France when not just the route, but the numbers of stages were changing year by year, there were even more rest days. The first Tour de France (1903) included only six stages, but the event was held from 1 to 19 July.
Nowadays, when even the teams and riders are creating online content everyday, is not that significant anymorey but for several decades
rest days were also press days.
For example, taking photos of the actual leader of the general classification wearing the yellow jersey while reading the newspapers with fornt page stories about the race was one of the recurring topic of the rest day pictures.
Although it's called rest day, it does not mean, that the riders do nothing at all. They usually spend the day in the saddle, go for a training ride. The rest days means only that they don't compet that day.