There are a number of reasons. I'm not sure how deep in the weeds you want to get with how equity markets work - behind the scenes, so to speak, with the processes that make the markets function. So I'll be fairly cursory for now. (I'm no expert when it comes to such things anyway. But I do have a decent-enough working understanding of them.)
Generally speaking, I'd refer to the roles played by shorting as: (1) liquidity, (2) hedging, and (3) more effective pricing / bubble mitigation.
Market makers - the entities behind the scenes who make efficient and liquid equity trading possible - sometimes need to short positions in order to mitigate the carrying risks they face. They aren't there to make money on moving share prices. They're there to make money on bid / ask spreads and, in doing so, facilitate trades for those who are trying to make money on moving share prices. They can't do what they do if they risk losing too much money on price movement. And all the equity investors who want to be able to easily make trades, and buy or sell their shares quickly at prices they think are right, need the market makers behind the scenes providing liquidity and efficient price matching. They're kind of (some of) the gears doing the work of actually making trades happen.
Further, various entities need to be able to short in order to hedge the risks they're taking. Hedging plays an important role in investment. And investment, or course, is part of what drives new business and job creation. Society, on the whole, benefits from risk taking in capital allocation and risk taking is often easier to justify when hedging is possible.
Perhaps more importantly, short selling is needed to counter the natural bull bias in equity investment. Short sellers aside, the parties involved with trading given equities are, on the whole and generally speaking, biased in favor of higher valuations than realities would have. The people who affect the price of stocks are the people who think the stock prices should be high. They're choosing to buy particular stocks or had previously chosen to buy them. They are less inclined to appreciate downside risks than people who wouldn't chose to buy those stocks. They benefit from prices going up. Without short selling, the people who recognize problems - or, just overvaluation - don't have an effective mechanism to weigh in and keep stock prices in check. Bubbles - in particular stocks and in equity markets more broadly - would happen more often and would burst more violently if short sellers weren't allowed to weigh in and exert bearish pressure on market prices. In some cases short sellers are the canaries in the coal mines, so to speak, sniffing out problems - accounting issues, fraud, poor business practices. Without the ability to short sell particular stocks, they'd have less incentive to identify such problems and less ability to convince markets of what they've identified.
As I've said numerous times, short selling can be abused. (So can long buying - what's happened with GameStop being a timely example.) But more often it's used for legitimate reasons and helps maintain efficient, liquid markets with better - though, of course, far from perfect - price discovery.