governments are not allowed to do anything that lowers corporate profits under these treaties. in this specific case the pollution was deadly and yet the treaty protects chevron's interest over those of the citizens and endangers lives
Well, the national government representing these citizens intentionally chose that attracting investment (which presumably helps their citizens in the long run) is more important to their country than protecting the health of their population, and as the sovereign, they can make that choice on behalf of their citizens. It may be a stupid or misguided or evil choice, but that's their choice to make.
Also, for many third world countries it does seem quite clear that simply setting the labor law and environmental law protections equal to first world standards would be a stupid policy harmful to their citizens; simple poverty kills and harms much more people in a much more direct way, and becoming a place for outsourcing is a net benefit to their population in the end; proper protection is a luxury that their society can't (yet) afford because they have to fulfil their core needs first even if that costs some lives due to pollution or exploitative labor. At some point they'll want to toughen up these restrictions (as China is doing now), but it's not because the lax restrictions were wrong or a regrettable mistake, it's only because the conditions have changed, they're richer, and now they can afford to be more picky about these issues. It's a tough choice to make this balance well, but it's not something that someone else can decide for them, the national governments are the ones that should be making this choice - unless they're totalitarian dictatorships, in which case the people should be given the say, but they won't without a potentially bloody coup.