Well that shows even someone as smart as Elon has his idiot moments. Twitter would be a perfect work from home company that he could eliminate all his facility and equipment overhead if he set them all to work from home
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.