I have spent quite a bit of time studying Elon Musk. A few years ago, I read Ashlee Vance's biography of him.
More recently, I read the fantastic series of essays about him by Tim Urban of Wait But Why. I also listened to the great podcasts that Joe Rogan did with Elon Musk.
Musk is amazing in how he looks at problems from the perspective of humanity's long term prospects.
Here is roughly the logic behind Tesla:
The world primarily uses fossil fuels. They will run out eventually. Then humanity has a huge problem. Humanity should switch to renewable energy as soon as possible to avoid that.
Transportation and cars running on oil are a big part of fossil fuel usage. Electric cars could run on renewable energy and help shift away from fossil fuels. But the car companies are happy with the status quo. So I go and build a new car company making an electric car that can compete in the market. People will replace their existing cars with electric and other companies will eventually switch too and then help shift the energy consumption of transportation to renewable energy.
And when you look at SpaceX, it's an even vaster perspective:
There is some chance we get hit by some disaster and humanity gets wiped out. And eventually earth and the solar system will become uninhabitable. So to survive in the long term, humanity has to be able to spread different planets and ultimately solar systems.
But as a start, even a colony of 1m people on Mars should be provide some insurance for a disaster on earth. But Nasa nor anyone else is actually trying to solve the problem.
What if I want to do it? The technology has to be built. So I go and build a rocket company that is able to compete with the existing rocket companies. That then is able to lower the cost of rockets dramatically and builds a city on Mars. And later provides transportation between planets.
I'm glad that Tesla has such a huge stock valuation. It means that people are giving Musk almost unlimited capital to pursue these goals.