I have worked previously in three companies where there were different salaries paid to different employees for the same job, same shifts and same responsibilities.
Sometimes, other factors are taken into account as well, such as qualifications, length of time in the company, previous work experience, salary increase every year based on the individual employee’s performance in the previous year. Some people are offered more than others to lure them into a job in the first place, and therefore may start on a higher salary.
I know that it can sometimes cause bad feelings, but I don't think this situation is all that rare, and I don't think there is anything legally wrong with it.