I think you may be confusing 2 things. H1 Validity and H1 Visa. You can extend your H1 from within US and most people do. No one is forced to go out and come back.
However, to extend H1 Visa, what you say is true. The difference is that visa allows you to go out of US, and then come back in, and for you to come back in, you need a visa that is valid at the time of entry.
However, if you wanted to stay in US without going out and keep on extending H1 (to the extent allowed by law), you can.
H1b applications processed by consulates don't receive an I-94 which means that the application is "approved pending a visa stamping". The new work authorization isn't active regardless of whether they are already in the United States legally or not, until the person leaves the US and goes to a visa stamping at a consulate.
You are describing the happy path for tech workers, but in my experience (90s Soviet block exodus) most families had to go through consular processing because it places a smaller burden of proof on the applicant vis a vis things like legal status in the United States and their home country. Lots of families from the Soviet block had a hard time assembling the required documentation in the chaos of the 90s and anyone who overstayed a H1b or student visa even a day because they wouldn't or couldn't uproot their families has to go through this process.
What I am describing about H1 is standard (majority) operating procedure. Yes extending H1 visa outside of the country is a pain, but extending H1 while being in US is not such a big pain, and most of my colleagues do that. Of course there does come a need for people to visit to their origin country once in a while, and yes that's when it becomes a lottery.
In order to renew an H1b visa [1], immigrants have to go to a US consulate, which do not exist within the borders of the United States so leaving the country is required. For the vast majority, this is a day trip to Canada or Mexico or a small vacation to visit family in their home country so it's not really an issue. However, sometimes, the consulate will pull shit like a "State Department Security Check" because the subjects worked in an institute that happens to have a research nuclear reactor - nevermind that it's one of the largest scientific institutes in the world or that their fields of expertise have nothing to do with nuclear.
The immigrants, if they chose to go to Canada or Mexico (as most do due to cost), are likely at this point stuck for months as undocumented immigrants in their new host country - unable to work with existing mortgages/apartments/cars/obligations to pay for in their old life, hotels and living expenses to pay for in their new life, and barely a month worth of sick time and vacation. Bonus: most of the things they could do to mitigate the disaster could jeopardize their permanent residency application. As far as I know, these standoffs usually end when the employers sue over the renewal or dump the employee completely in which case their entire lives have to be packed up and moved but they can't enter the United States to do so. Bonus #2: if both parents are working, they likely have separate H1b visas that won't clear together - family separation time!
As you can imagine, going through this series of events is devastating, especially for children who have zero insight or control into the process. Cruel is an understatement.
Edit: [1] See comment below, this applies to applications going through consular processing, which is a crucial detail