I am a long term investor. Long term investors like me still need to buy or sell stock occasionally, even if only to live out their retirement eventually.
There's no good reason to assume that for every long term who wants to buy or sell on a particular date, there will be another long term investor on the other side of the deal.
So a special kind of short term investor, called a market maker, jumps in. Market makers typically hold a small amount of inventory and offer to buy or sell stock.
Market makers allow your grandma to sell stock any day of the week without worrying too much about timing.
See https://en.wikipedia.org/wiki/Market_maker
There are other kinds of short term holders of shares. But market makers are probably the most obviously useful to long term investors.
It turns out that is one of the most important things to do in modern, capital intensive, economies.
It also means people can invest for shorter periods and that means more capital is available for investment. This has a double bonus where it reduces the risk of investments again making more capital available...
Imagine if you're a would be investor. You're money is available now to invest. So you want the market to be open to let you buy. Otherwise that cash is just sat there waiting. Similarly, you want to invest all your money. But if you know you won't be able to get it back for X period of time then you can't can you? You might not even know how long you can invest for: I might reasonable expect not to need some cash till Christmas time but if I lose my job tomorrow I want it now please!
So a market where you can buy and sell rapidly makes you more able and more likely to invest. That's good for you as you can use spare cash productively and make a profit while still being safe if you suddenly have a change in circumstances. It's also it's good for the company you're investing in as they can raise capital quickly and there is more capital available. And all of this means more growth and lower costs and that means more tax money for social services and more jobs for other workers etc.
The analysis for the people receiving the investment is similar but a bit more complex because the company doesn't just get investment, it also get's information: a rising share price tells you you should expand, high prices in general indicate a great time to start new businesses, a competitor whose share price falls while your one rises has issues and might be open to a merger\takeover etc.
Compare football (ie soccer) trading windows. Player performance within a match might be like daily performance of a company.
If you had to hold a stock for a long amount of time before selling it, you would find it very hard to buy or sell stock.