Remote work is good for certain types of work, particularly if you have a mature group of employees who already work together well, work well within an existing hierarchy, or can work well independently.
A company in a state of flux, bloated with entitled do-nothings, insider threats, and new management that wants to streamline the entire codebase yesterday... bad fit for remote work.
Musk needed to establish control over a company that was in a state of mutiny, and he needed to do it quickly. It came at a cost, but the cost of not squashing the mutiny was going to be much greater.
Twitter after that massive personnel upheaval and codebase refactoring might be a good candidate for remote work again, and with the layoffs, it would certainly save money by renegotiating or leaving its real estate agreements, but in those first months, it was a necessary call to pull people back into offices, even if some really good talent left because of it.
Might work well for small companies. Or if you are a talented employee with an impressive track record. So that's not going to apply for most peons (90% of us).