Lots of people assume that the valuable thing is the direct business, but a business can be a lot more than that. A competitor may buy you for your engineers or sales team or patents, or assets, or whatever (e.g. Siri, Motorola, etc)... and just toss the rest of the business or sell that stuff off after they have what they want. In other industries they may just buy companies for their assets. Also you never know what will happen with a pivot (e.g. twitter, slack, etc).
The bleak reality is if you can keep growing (making more money than you spend) that alone is usually desirable enough for people to keep giving you money and eventually provide an exit. Why? because it's really hard to do. Its a skill.
And I have to say that no one tries to build a failed business. Founders can be really earnest about their intentions, work harder when they see the cracks, but often it just doesn't work, they don't find the right way before it's too late.
Maybe just before the end someone tries to siphon the funds into private account or assets into their next venture, but you tend to get caught doing so.