If everybody agrees not to pay ransom and follows through, criminals won't try to hack companies to collect ransom.
But as an individual company, you can't coordinate with everybody else to prevent everybody from paying ransom, so not doing so puts you on disadvantage.
Philosophically, the usefulnes of government is to threaten violence to solve the coordination problems amongst individuals.