Some companies underpaying part of their staff for the same job doesn't make it moral. In some cases, it tends to correlate with genetics which makes it even more questionable. A black box algorithm may unknowingly introduce such bias.
Anyway what is moral depends on your personal values, not the law nor how things are done, it's expected to disagree.