The designation of a car as "totaled" is often an illusion and there is a thriving parallel market of auction houses, repair shops, salvage titling companies, and resellers who take the "ruined" cars, fix them, and sell them on the used market.
Insurance companies could deal directly with the lower cost shops but just like the Concur Travel cancer that is spreading across corporate America there are extremely perverse incentives between executives and boards to keep the system the way it is with all of the major players dealing only with each other.
There is probably an auctioneer within 30 minutes of where you are right now who will sell you a "total loss" car that you can repair, or have repaired, for a minuscule fraction of what an insurance contractor will charge-- often for less than the insurance payout (to both you and the adjuster).
Like all things fucked in our economy, the trend of exorbitant repair costs took off when private equity started buying up the regional insurance repair contractor near-monopolies like Service King (Carlyle Group) and Caliber Collision (Leonard Green).