Publicly disclosing the algorithms would drastically increase the pace of gaming them and resulting in pay to play system where the fanciest SEO wins.
Google and Facebook partially relies on the obscurity to keep the fighting the spam battle. IMO we don't have the technology yet to have fully open ranking algorithms that are not quickly broken.
Google's best asset for ranking is their user data. Even if you had the exact algorithm, you couldn't game it without massive amounts of user traffic. (At least not for popular searches.)
delegating the war against spam rather then being picked up by the user doesn't seem right. To give Big Tech such power to relieve ourselves of a mild annoyance is destructive. This is understood in other aspects of life Hence we have local governments which are inefficient and inconvenience people greatly. Yet it is found that selling all our problems is counterproductive. It ends with monopolies. The answer to this isn't to charge tech companies for the privilege of dictating our lives, rather, it's greater accountability on behalf of big tech and more responsibility on the part of consumers. The only cure for google domination is for the transfer of information online to become more democratised.
This excuse has been used to protect Google and Facebook for decades, but considering disinformation campaigns, civil unrest, and outright genocide has been the cost... I think the price of using obscurity to prevent SEO tactics is way too high.
The root cause isn't algorithms, it's a lack of accountability (both of companies and of users). The problem with 8chan wasn't some inadvertently harmful AI, it's that the site and its users damaged the world for several years without facing consequences.