Stock markets were invented originally by the Dutch East India company to raise funds from the general public. This allowed them to raise the capital to expand faster than any other firm in the world, at a time when the alternatives were to convince royalty to grant you money, turn to high-interest small loans via moneylenders, or raise from your own stakeholders (e.g. guild membership).
At its height, the value of the Dutch East Company dwarfed the value of the top 40 global companies today, combined, FAANG included. Ever since, companies have sought to issue stock to the public (IPO).
Originally, the reason to buy a stock was because the company offered dividends to their shareholders. Over time, people started trading their shares of the stock (hence stream of future expected dividends) to others for cash now.
The 'stock market' became a meetingplace for those transactions. Just like other marketplaces (e.g. AirBnB), the stock market makes it easy for buyers to discover sellers and vice versa. The ability to trade assets for cash is 'liquidity' and stock markets have proven to be highly liquid, which is one of their most important qualities. Over time, these meetingplaces became regulated by governments to prevent schenanigans (e.g. Great Depression).
Originally, companies didn't care that much about their stock price after they initially raised the funds from the public. The price of stock was directly tied how much in dividends you would expect from the future, which is a proxy for the health of the company, but that's about it.
Over time, investing into these stocks became its own profession, and investing professionals developed a lot of metrics to assess that health of the company. Methods include looking through the company's balance sheets, assessing their strategy, comparing them to competitors, etc. Think of jargon like EBITDA, Free Cash Flow to Equity, Debt Leverage - there's over 20,000 pages of it throughout the CFA exam series.
Jack Welch is credited with shifting the focus of companies towards increasing their stock price by gaming the investors' metrics. Improving these metrics will have immediate effects on investor perception, much moreso than gradual adjustments to dividends. Employees and managers, who owned a bit of the company stock, would try to do all they could to amp up the price so they could sell their own shares at a high price.
Incidentally, this is the same angle for most tech stocks / VC. Tech companies generally don't focus on paying steady dividends, but rather on growing and raising the stock price to the point where you can sell it to someone else at a higher price. Hence, many tech companies are fine with being unprofitable for a long amount of time, even during an IPO, as long as the valuation of the company (# shares x price) rises via growth.
Re: Republicans, you are actually 100% correct in your suspicion, at least w/r/t the USA. Reagan changed the tax code in the 80s, around the time Welch was in his heyday, to incentivize citizens to invest in the economy. Now over half of American adults are invested in the stock market, which is among the highest participation rate of any country. In other countries, such as China, the stock market doesn't have nearly as high of a % participation from the public.
Reagan's policy is regressive. Only the people with well-paying jobs with 401ks typically invest, so the poor fall farther behind. Furthermore, to take full advantage of the investment tax incentives requires knowledge, which is typically passed down via family rather than taught in schools. This is a substantial driver of inequality.
Here's a short blog/article I wrote about the history of shareholder rights from then till today https://www.yourstake.org/academic-impact/