Dominance hierarchies in vertebrates emerge as individuals in social groups attempt to find their place relative to others in the group. Pecking orders are established in groups where each individual is ascribed a rank relative to the others. Challenges between individuals that result in the determination of their relative positions help to prevent a confrontation each time they meet.
On the ends of the spectrum of social hierarchy there is egalitarianism on one end, where all individual members are of the same rank, and despotism on the other end, where one individual is dominant over all the others who are submissive.
Pecking order is between these extremes. The ability of individuals to recognise each other as members of the same group, as well as their ability to learn within this social structure, enables the establishment of dominance hierarchies.
The positions of individuals in the hierarchy is established through the outcome of confrontations. There are a few aspects of a confrontational situation that have a role to pay in determining the outcome: resource-holding potential, resource value and intruder retreats.
Resource-holding potential refers to the ability of one individual to defend its resources. Ability to defend results in little need for physical confrontation.
Resource value refers to the fact that animals that are more invested in the resource are more likely to engage more in the fight.
Intruder retreats refers to scenarios where an individual confronts another one over a territory or resource that is seen to rightfully belong to the other one. The animal who believes itself to be the owner will win the contest. If both believe themselves to be the owner, the one with the highest need for the resource will fight the hardest.
In dominant-subordinate group hierarchies, advantages to having a higher rank include better reproductive prospects and food (potentially at the expense of long-term fitness lost to conflict), while advantages to having a subordinate rank include potentially better long-term fitness from avoiding harmful fights, sneaky mating and occasional victories for mating opportunities (at the expense of overall lower reproductive success and decreased access to nutrition).