You are assuming that the government is going to use those resources better than the company avoiding the taxes. Not everyone agrees with this. From this point of view everyone is acting rationally, they only might disagree about one specific assumption.