A very simplified version of what's going on is the company raises capital by selling a portion of itself to the investors — the first purchasers of the stock. The existing owners allow this in the belief the capital raised from this one time sale will be used to increase the value of the company enough so they are better off than before.
When you buy a stock, you're buying a very small ownership stake in the company*. Buy enough of a company's stock, and you get a say in who gets to sit on the board of directors for the company, and therefore a say in what the company does and how it behaves. This is part of what gives a stock value on the open market.
The other way a stock has value is through dividends. A business exists to make money for it's owners. That is it's purpose. Large public corporations are no exception, and they do this pay sometimes paying dividends to their shareholders. So owning the right stocks means sometimes getting "free" money above and beyond the value of the stock itself.
But the important thing to understand is the stocks are a one-time sale for the company. They get their capital once from the initial sale, and don't have a stake when the stocks are bought/sold afterwards. They care about the stock price, because the shareholders who own those stocks own the company. If the stock performs poorly, the shareholders will get the board to replace the company's management team (by first replacing board members if necessary).
* This is gross over-simplification. In reality, there are different classes of stock, and the casual investor rarely ends up with stock that grants any real ownership interest