Because that way they avoid any competition.
Thing is, businesses like Google’s ads are not linear. If you can track 90% of people 90% of the time, your ads are much much more valuable to advertisers than a company that only tracks 70% of the people 90% of the time. So it makes sense to create a moat by literally shitting money on everyone around you.
Think about the opposite: if Apple would switch to DDG by default, most people would leave it at that. And that would mean, a significant chunk of the US search traffic is gone. Europe and the rest of the world are not that apple-heavy, but Apple users are rich power users (on average), these are extremely valuable.
I feel like there’s a very fine balance for the effort required to publish a package.
Too easy and you get npm.
Too hard and you get an empty repo.
I feel like Java is actually doing a relatively good job here. Most packages are at least documented a bit, though obviously many are outdated.