So if you tell someone your salary, your job probably feels more difficult to you than it looks to them, and you probably feel more productive than they think you are. If you make the same or more than they do, there is a very high risk that they will think you are overpaid.
This is obviously a risk to the company, which is why most companies (at least in the US) have a policy against it. But it is also a risk to you and your relationship with that other person, which is why few people share their salary information with their friends.
You are right that this is a fundamental problem for equality. But it is not an easy or safe thing to change, which means it will take a lot of time and effort.
I am not saying that the status quo should remain. I'm just pointing out the reason it is difficult to change.