In the first instance, employers generally set wages based on the job description: a janitor is paid a janitor's wage and a surgeon is paid a surgeon's even if the janitor is a qualified surgeon. The amount of these wages are, broadly speaking, set by a combination of minimum wage laws and economic market forces.
People get paid different amounts for different jobs. For example, while it may be wildly unfair that Hugh Jackman earns 100x per annum more than I do despite us both being the same age, ethnicity, sex and city of origin and the fact that I have 2 Master's degrees and he doesn't this simply reflects the fact that people at the top of the acting profession command a greater income than those at the top of the engineering profession.
People doing the same job do not have to be paid the same amount. All else being equal, an employer would prefer to pay less and the employee would prefer to be paid more, however, both are constrained by the availability of replacement labour (for the employer) and alternative employment opportunities (for the employee): these things are mutually interdependent. In addition, even in non-profit sectors like governments, an employer is looking to maximise productivity - an employee who produces more in a given time frame is worth more to the employer, a wise employer will be willing to split this increased productivity with the employee in order to retain them, subject to cultural and operational constraints.
Government departments, however, tend to be more culturally constrained about paying people different amounts for the same job title and more hierarchical in pay scales. As a private sector employer, I don't believe any of my employees earn the same amount, either per hour or per annum, and I know of several nominally subordinate employees who earn more than their supervisors because the former are of more value to me than the latter: such things are much less common in the public sector and in larger businesses in the private sector too.
Anyone can ask for a raise at any time. The request will either be refused, accepted or be met with a counter-offer. A request will be more likely to get a favourable outcome if the employee is specific about why they are of greater value to the organisation - comparisons with other people are generally not the best way to go with this.