So much of the internet famous generation got rich by doing something, giving it away for free, then making a pile of money from giving it away for free. From bloggers to vloggers to streamers to influencers to banksy to almost every tech company. The outlier of sorts is open-source developers.
To be honest I have no answers to the problem, and personally find most of the answers that do get thrown around dont pass the most basic of logic tests. So like you the only option I see is for developers to make the change, stop the freedom and the free ride.
Really, from the outside it looks silly - "I gave my code away, and now I'm not profiting from it!". Then at the same time all of the biggest, richest companies in the world are software companies because they chose not to do that.