This is useful for reusing and writing clean workflow code. For example, I might have a secret DEPLOY_TOKEN in my environment "prod", and the same secret with different value in "dev". This allows an action to simply deploy using the same secret name all the time, and the set environment decides the value (and if it's allowed to be used).
This becomes especially important when the number of environments grows. With environment secrets, the workflow code stays the same, but without, the code has to be modified and grown each time a new environment is added.
Github repositories has a neat feature where one can specify a set of environments with their own protection rules. https://docs.github.com/en/actions/reference/environments#environment-secrets
This is useful for reusing and writing clean workflow code. For example, I might have a secret DEPLOY_TOKEN in my environment "prod", and the same secret with different value in "dev". This allows an action to simply deploy using the same secret name all the time, and the set environment decides the value (and if it's allowed to be used).
This becomes especially important when the number of environments grows. With environment secrets, the workflow code stays the same, but without, the code has to be modified and grown each time a new environment is added.