~30 years ago (in 2002), the Sarbanes-Oxley Act was adopted. In the wake of scandals like Enron and WorldCom, it imposed a bunch of new rules that make being a public company more expensive. At the margin, that would impact the count of public companies.
It's also much easier to raise money for private startups. Back in the day there was a point at which you _had_ to go public in order to finance your business. Now you can have raises like the recent $122 billion OpenAI raise. https://openai.com/index/accelerating-the-next-phase-ai/