It is a great business to be in, they just aren't run by a sane person who is good at business. If it weren't for massive conflicts of interest their CEO would have been fired years ago.
They're getting leapfrogged by Chinese companies despite being extremely early to the Chinese market along with a factory in China.
They've somehow squandered their technology lead despite being profitable and scaled unlike some of the companies leapfrogging them.
They botched the Cybertruck so badly. Imagine an American company failing to make a popular pickup truck. They could have been selling pickup trucks at F-150-like volume and profitability.
Their brand image of tech futurism is outdated and they're squandering the most profitable segments of the automotive market. Just look at stuff that's succeeding and pulling in big money like the Bronco and Toyota TRD lineup.
Tesla is retreating to robots because their CEO gets bored of running scaled companies that aren't startups, and they're also doing a whole bunch of financial manipulation to prevent Tesla stock from crashing due to its fundamentals. Without a future moonshot business, the valuation of the stock makes no sense, and would naturally decline to that of a normal automobile company otherwise. That event would destroy Elon's net worth and probably make him default on a bunch of personal loans. By combining other moonshots like xAI and robotics, it lessens the impact of the reality of the automotive business: a profitable but generally low-margin high-maturity type of business.