You would think that, but imagine you are making less than someone who does less work than you, or is clearly less skilled. Although you might initially blame the company, you may grow to resent your coworker who is getting more for less. Especially if it's a lot more. You can't really start making more demands of them because they make more, or else slack off because you make less.
I think there are situations where secrecy can be good and others where it can be bad. When salaries are public and negotiated by groups, that can lead to other worst-case scenarios. Your company can always decline to pay you more by coming up with a delusionally low pay scale, while claiming the high ground of fairness or some shit. When people can negotiate for more, they can potentially raise the bar gradually. And with the legal protection behind salary disclosure, and websites that make it easy to share your salary, I think it's better to let salaries fluctuate with the market. It might be nigh impossible to demand a raise without switching jobs, but at least the current norm lets employers effectively bid on you.
Now suppose after 5 years you found out that coworkers were being paid twice your salary for the same work, and had been for years.
It seems to me that you want to find this out sooner rather than later.
At one job where I was perhaps making 70% of what my coworkers did, and I found out a couple of years before I was able to leave. It did upset me a lot. I knew I was underpaid before that because of how other companies paid, but knowing specifics definitely rubbed salt in the wound. I suppose knowing specifics might be a necessary evil but I think back then it might have been better to not know. On the other hand, that experience set me down a path that eventually worked out ok, so I can't really say I wish I didn't know.
I am 99% convinced that pay secrecy primarily benefits employers and management at the expense of most employees. It creates an asymmetric information environment that makes it difficult for employees to negotiate raises or even to be paid market wages.
The 1% uncertainty is that government jobs (which have pay transparency) tend to be underpaid, and the rare (?) private workplaces with pay transparency don't seem to have done much better than their pay-secret counterparts, with the exception of law firms, where the associate/partner model seems to have caught on. Union negotiated rates seem to have up and down sides.
Of course, you should really consider how much money the company is making, where it is coming from, and how it is being spent. In my experience, (non-founder) technical staff members are often paid very poorly compared to the money that they bring into the company, even after considering large amounts of overhead, expenses, benefits, taxes, etc.