There are some economic theories about non-monetary compensation that try to explain this. Basically:
Total Compensation = Salary + Benefits + Intangibles
Those Intangibles can be things like working environment or commute, but they can also include your affinity for the organization’s mission. People are willing to take smaller salaries when they’re working on something they love & respect. It takes more money to convince people to work on boring or undesirable things. It’s the exception to be paid well for something you like.