Tesla is coming out with their IPO shortly.
Toyota has agreed to buy 50 million worth of stock at the IPO price as an investor.
They arent buying the company, they are just investing in it. By doing so they will probably get a seat on the board and be able to persuade Tesla to work on projects that would benefit them too. It also builds up investor confidence when a big company decides to invest in you.
A company I used to work for was partners with Microsoft on their Windows 2000 project and we helped them with some stuff and they gave us free advertising and agreed to buy some of our stock so they could be investors. As a result, both companies profited.