Countries agree historic deal to protect nature