I know some people really like playing d&d as a sandbox. However it seems to me that the rest mechanics have never worked well for that style of play. Am I missing something or are some people just trying to fit a square peg into a round hole?
Works fine for me. The main thing that changes between tailored linear play and sandbox play is that you can no longer rely on finely-calibrated encounters N times per day--it's kind of like the classic difference between being on level N of the Gygaxian dungeon (filled with level N stuff) vs. being in the wilderness (filled with who-knows-what, how-many-times-per-hour).
Sandbox play is not "safe" by default. You have to
make it safe(ish) through good play. Having a variety of different rest mechanics in your party is a good thing because it means that even if you get unlucky and nearly wiped out by the T-Rex stampede, the (long rest) wizard can pop up a Rope Trick for the party to go and hide in for an hour so that the (short rest) warlock and the (semi-short rest) druid can get some juice back, as well as the wizard getting a trickle of power back via Arcane Recovery and everyone getting to spend some HD.
Other important aspects of sandbox play include the necessity of telegraphing (in general terms) what the danger level is of a particular region or encounter so that players are not surprised (i.e. tone down the who-knows-what factor, either by overt clues like mangled bodies or through more subtle and optional stuff like rumors the PCs can listen for or sages they can consult), the need to for players to take the strategic initiative in deciding what their goals are, and the need for DMs to be aware of the difference between sandboxing and "realism". If the goal of your sandbox is to maintain a high degree of player agency, it isn't necessarily the case that you have to avoid exciting, adventurous coincidences.
Quick example:
In a sandbox emphasizing "realism", when the PCs get shipwrecked on a beach, the odds of there being an invading undead army that shows up on that beach will be bounded by the number of invading undead armies that can plausibly hit the beaches every year divided by the number of beaches in the world. It's probably going to be a relatively tame beach in this case.
In a "sandbox" emphasizing player agency, when the PCs get shipwrecked on a beach, the odds of there being an invading undead army depend on a fine balance between pre-established game factors, the players' intent as expressed through their previous actions (did they do anything to
avoid running across undead armies? Divination spells, etc.?), and the DM's sense of both fun and plausibility. It can be okay for the PCs to be Weirdness Magnets, especially if the players are okay with being Weirdness Magnets--but it's still a sandbox as long as the players are allowed to choose their own mode of engagement with the weirdness they encounter. (Fight the undead, hide from the undead, infiltrate the undead and try to take over the army, etc.)