The social function of the stock market is to make sure the companies with the best prospects have the cheapest access to capital (should they issue equity), and to reflect intrinsic values of companies (so you can invest today at an adequate return). Neither of those are helped by creating a bubble in the share price of a failing retailer.
Going by your own criteria here, we can look at exactly the problem with the financial entities in everything from LCTM to the derivatives crisis that crashed the market in 2008 to the current situation. The financial sector entities were not investing and helping any "company with the best prospects" and that was the problem (we can talk about retail investors in a minute). The problem is quite simple really: look at the incentives. Do the incentives of the private actors align with the stated purpose of making this behavior legal? When things are too deregulated there is simply too much opportunity for misaligned incentives.
There were many moving pieces to the derivatives crash of 2008 but at its heart, it was two tiers of misaligned incentives. The purpose of home loans is to allow people to get into a home they can afford. When banks hold those loans, they have the incentive to make the best loans possible. However, when deregulation and rules changed, the non-bank mortgage lenders (Countrywide and dozens of smaller 'chop shops' who were the bulk of the bad loan origination) had different incentives than what existed in the housing market for decades and decades. Countrywide had no incentive to make good loans, they had incentive (for personal profit) to make bad loans because they were holding those loans. And it wasn't just subprime buyers either, they were making bad loans to people with good jobs by simply selling houses too big than what the buyer could afford. They were chopping up the loans and selling them ASAP to investment banks like Bear and Lehman. Since they were selling their bad loans, their incentives were no longer aligned with the original purpose of home loans. Bear and Lehman had other issues. First, they were manipulating by getting chopping up mortgage rated Triple A when the packages were simply not as safe as US Treasury bonds.
This leads into the problem with over-leveraged entities. These entities simply shouldn't be allowed to leverage up to the 20, 30 times their cash because those problems don't just affect them. That's part of the issue here with GME and the short funds. First, they are deviating from the whole purpose of allowing these actions (in your words "make sure companies with the best prospects have the cheapest access to capital"). These were profiting off of influencing what those best prospects even were. Before any retail investors go involved, these financial sector entities were shorting at 120% of the company shares available and up to 140%. That, in no way, is responsible nor serving your social function. That's groups of people in the know with access to greater tools than the public has available (both larger capital and information) trying to cause a company to go under on their time frame so they can profit. That's not performing a positive social function. It's carving profits out of a naturally functioning market.
Now enter retail investors. First, they didn't initiate this circumstance. They didn't set out to create a bubble.Some smart people saw that 1) these funds were going too far by shorting over 120% of company stock and 2) GME was actually stronger as a company than the shorters were trying to propagate. For instance, many of the actual GME stores were positive - they were turning a profit. The company actually had better prospects than the narrative trying to be enforced by the short-sellers. The short-sellers weren't just investing in companies with the best prospects, they were trying to artificially sink the prospects of a company so they could personally profit. And they were not performing a healthy risk management either.
So the retail investors can't be blamed here for reacting in a perfectly logical manner to the shorts over-leveraging and trying to influence natural market progress. Then sure, some retailer investors got to a point in the story where they weren't even trying to profit. They simply wanted to help crash an overleveraged financial services entity that was failing to perform a beneficial social function.
That is perfectly logical too when we understand that people are not always "utility maximizes". In countless, behavioral economics experiments we've found that people will enforce "fairness" even at the cost of personal profit. The classic example is the ultimatum game. In short:
Two people are set up with $100. The first person divides the $100 between the two. The second person then decides whether both of them keep the divided money or they both get nothing.
The classic theory says that the second person will take whatever deal they get because walking out with $1 is more than walking out of the room with nothing. That is utility maximization. In classic theory, everyone will just accept the division. But what actually happens is people tend to reject offers that are too unfair. Someone divides the $100 with a 90-10 ratio and a large percentage will reject the division and walk out with nothing to "punish" the divider for being too greedy and not sharing fairly.
That concept is what's at play with at least some of the retail investors. They are enforcing a concept of fairness and willing to take or risk a small loss of money in order to help the shorters walk away with 0. That's a perfectly natural reaction to what's going on and it's 100% the fault of the shorts.
The main theme here is that the financial sector needs more regulation not less. Whenever these entities are too deregulated they find ways to risk the greater economy when seeking personal profits at all costs. it wasn't the Redditors that created this current instability it was the short funds.
While researching the potential negative effects of "viral investing" is definitely necessary, they weren't the problem here. The funds were. A viral mass of retail investors did not wake one day and say "hey, lets all overvalue this one stock for shits and giggles and see what happens." Their behavior was, for different reasons, a direct response to the behavior by the short funds. Some began investing because GME was undervalued due to the shorts, others saw a way to make a little money, others jump on just to punish the hedge funds for not being fair, some just wanted to take part for the fun.
And I haven't touched upon the problematic conflict of interested in Robinhood's behavior and their CEO lying his ass off all over media.