I've spent the bulk of my career being paid to write software that was published under open source licenses. I was paid to write exactly the software the business needed to be built, with software being the tool for the business to provide value to their customers and not a money extracting scheme.
I've also worked on complex web applications/systems, where operation of the web site is ultimately the cost that needs to be continuously borne to extract profit from software itself. Yes, someone else can optimize and do operation better than you (eg. see Amazon vs Elastic and numerous other cases of open-source companies being overtaken by their SW being run by well funded teams), but there is low risk of illegal use in this case.
Today I am paid to write software that the business believes will provide them profit that will pay for my services. The software I write is tied to a physical product being sold and is effectively the enabler and mostly useless without the physical product itself.
Other engineers at the company I am at are building software that requires a lot of support to operate as it manages critical infrastructure country-sized systems, and ultimately, even if someone could get this software without paying a license, they'd probably have no idea how to operate it effectively.
Most of the internet infrastructure works on open and free software, where at "worst", copyright protections are turned upside down to make them copyleft if software is not available under more permissive licenses like MIT, BSD or even put into public domain.
Companies that used to pay best SW engineering salaries like Google, Meta and Amazon would likely not face any significant business loss if all of their software (source code included) was publicly leaked: SW is a tool for them to provide an ad platform or cloud infrastructure service.