In the US at least, employees are explicitly allowed by federal labor law to discuss compensation with each other. Employers generally can't retaliate against them for doing so (although like all labor laws that one is occasionally broken).
Can it be explained on the basis of value? If so, then good. If not, then it's likely unfair.
"It can also create resentment if others knew that someone was overpaid."
How can they be overpaid? The salary was set by the market. If the others are underpaid due to lagging the market, then they might just leave anyways. Their value has changed during their tenure and the company has not adequately adjusted for that to stay competitive in the market.
This should really end. Job hopping should not be necessary to get a decent wage.
In plenty of companies I have worked for, you pay quite a lot more than you want for a particular hire not necessarily because they are worth it but because you are desperate and they are nearly good enough. You generally don't get away with putting people's salaries down if they don't perform and if you did, they might leave ending with you being back in the mess.
This might be magnified in smaller companies but it could easily squew salary figures and depending on their sex, it could also make the figures look really wrong.
This might be "unfair" by one definition but it definitely happens and is one reason why it is hard to be transparent about wages. It can also create resentment if others knew that someone was overpaid.