A very simplified version of what's going on is the company raises capital by selling a portion of itself (an ownership stake) 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. This kind of thing must be approved by the company's board of directors, which exists to act on behalf of the shareholders rather than the management team or employees.
When you buy a stock, you're buying a very small ownership stake in the company1. 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, or even a potential claim on its assets. This is part of what gives a stock value on the open market2.
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 by sometimes taking a portion of their profits and paying it out to shareholders. That is a dividend. So owning the right stocks means sometimes getting "free" money above and beyond the value of the stock itself. A stock with a reputation for paying dividends may have more demand, and therefore a higher stock price3.
But the important thing to understand is the stocks are a one-time sale for the company. The company receives capital once from the initial sale, and doesn't have a stake when the stocks are bought/sold afterwards.
The company does still care about the stock price, though, because of 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). Or they'll sell the stock in order to purchase another stock that is more valuable, which helps the stock price trend lower-still, which will further encourage other share holders to take action.
The other thing that can happen if the stock prices trends too low is the company becomes vulnerable to take-over by a rival. Remember ownership of stock is ownership of the company, and a rival need only purchase 51% of the stock the control the board — often even less if there is a sympathetic investor with the ailing company. Thus a low stock price can be dangerous for a company's very existence.
In other words, if a C-level executive wants to keep that nice six or seven figure salary, they better keep that stock price healthy.
Of course, you, I, or any other average Joe are unlikely to ever reach the level where we have a meaningful reason to attend a shareholders meaning and actually vote on anything that matters to us. We don't really care about the ownership stake so much. We do care that the stocks have shown stable and even increasing value over time. This makes them a useful place to park savings, that might even provide a good return. As a practical matter, the stock market as a whole cannot indefinitely out-perform the general economy, relative to the portion of said economy devoted to investment practices. Over time the stock market and larger economy should rise or fall at about the same rate. But there are variances between the two, and individual investors can sometimes do very well for themselves this way.
1. 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
2. This has interesting implications in the face of investment vehicles like mutual funds, where you don't own shares in the fund companies directly. Instead, you own a share in the fund. You give up any ownership voting rights you may have had, and instead help the fund managers (often banks) amass larger stakes in a company than they could using their own money.
3. In practice, dividends also have some negative attributes, such as higher tax rates, that don't attract as many investors as you might think.