No one really knows when The Second Shepherds' Play was written, but popular estimates place it somewhere between 1400 and 1450. For those keeping score, that means anywhere between the reign of Henry IV through Henry VI, and possibly as early as the reign of Richard II. This was a particularly tumultuous period in English history, and it closely follows one of the most devastating times Europe has ever known.
In the mid 1300s, the Black Death ravaged Europe, killing roughly 1/3 of the population. The bulk of these were from the peasant classes, which created a severe labor shortage. Appalled by the sudden power of the peasantry to demand higher wages, Parliament passed the "Ordinance of Labourers"in 1349, and then the "Statute of Labourers" two years later. These laws set a maximum wage at pre-plague levels, and required able body individuals under the age of 60 to work. Hugely unpopular, these laws helped fuel Wat Tyler's Peasant Revolt of 1381, and possibly Jack Cade's Kentish rebellion in 1450 (Shakespeare conflates the two in 2 Henry VI, and there was a significant amount of literature from the 1380s on both sides of the Peasant Revolt.
The complaints of the shepherds are grounded in the sorts of complaints the peasants revolted over, in both 1381 and 1450. The laws of England provided severe restrictions on their daily lives, and minimal social protections. Those with even a little bit of land or money held enormous sway over those who had little or none.
One of the reasons why I really like The Second Shepherds' Play is that the birth of Christ doesn't make things better. They are still cold and hungry, but now also have hope of something better in the life to come. The shepherds begin to see the pains of this world as transient things in the face of a promise of greater equity than they could ever hope for in this world, and a life in a land of plenty governed by a greater king than this world has known.
Peace, stability, and prosperity were meaningful promises for men who lived at the subsistence level in medieval Yorkshire. Even if the world isn't perfect, faith and right religion at least gives the shepherds a glimmer of hope for something better. In a world thick with disease, hunger, rebellion, and poverty, a little bit of hope can go a long way.