Pastoral plays were a common genre during the Renaissance period. They idealized country life and presented this world as almost Edenic in its innocence. As such, these stories were less interested in presenting the actual hard work of rural life and more intent on providing a sense of escape from the hustle and bustle of cities. Shakespeare had pastoral elements in a few of his plays, such as The Two Gentlemen of Verona and The Winter's Tale, but As You Like It is his fullest exploration of this once-prominent genre.
The setting of the Forest of Arden is entirely pastoral, a space populated by shepherds and displaced courtiers on the run. It is contrasted with the corrupt, artificial world of the court, where Rosalind finds herself endangered. In Arden, nature becomes a healing force, allowing Rosalind and Orlando to form a relationship and bringing the villainous Duke Ferdinand to his senses.
It must be noted that Shakespeare does complicate his presentation of country life by pointing out that such a life is not always easy. In act 2, scene 1, Duke Senior is just as apt to point out that nature can make life away from the controlled setting of the court difficult:
Now, my co-mates and brothers in exile,
Hath not old custom made this life more sweet
Than that of painted pomp? Are not these woods
More free from peril than the envious court?
Here feel we but the penalty of Adam,
The seasons' difference, as the icy fang
And churlish chiding of the winter's wind,
Which, when it bites and blows upon my body,
Even till I shrink with cold, I smile and say
"This is no flattery: these are counsellors
That feelingly persuade me what I am."
Sweet are the uses of adversity,
Which, like the toad, ugly and venomous,
Wears yet a precious jewel in his head;
And this our life exempt from public haunt
Finds tongues in trees, books in the running brooks,
Sermons in stones and good in every thing.
I would not change it.
Despite this harshness, Duke Senior still feels rural life is preferable to city life. Other little jabs at the pastoral such as this are present in As You Like It, but overall, the story tends to play its pastoral tropes straight.
As You Like It is a pastoral play because it is set primarily in the Forest of Arden, an idyllic natural setting that includes shepherds and shepherdesses. The Elizabethan and Jacobean pastoral depicts an artificial—what the critic Raymond Williams calls an "enamelled"—natural world of common people who do no real labor and courtly aristocrats playing at living the rural life. It does not depict the real world of rural labor but a utopic or counter-cultural space uncorrupted by civilization where alternative ideas can be explored.
Shakespeare's As You Like It is a classic pastoral. Aristocrats, such Rosalind and Celia, the niece and daughter of the evil Duke Frederick, run away to the forest, where they are followed by the aristocratic Orlando and meet up with banished Duke Senior and his recreated pastoral 'court' of followers. Add to the mix the shepherdess Phoebe, who rejects the love of the rustic Silvius, and all the elements of a pastoral are in place.
Shakespeare uses the idyllic world of the pastoral—a world where the audience and the characters can explore the world as they would like it to be, hence the title, As You Like It—to explore both gender-bending (Rosalind disguises herself as the male Ganymede to protect herself and Celia) and an alternative society built on kindness and love rather that cruelty and fear. It depicts the world as we would like it, not as it really it, and sometimes we simply like to lose ourselves in that fantasy.
Pastoral literature celebrates the freedom and purity of life outside the city, in the rural areas. Unlike in real life rural areas, characters in a pastoral play don't need to work hard all day on a farm or go hungry when the rains don't come. The genre glorifies country life as a refuge from the corrupt society of city life, showing the love affairs and antics of shepherd and shepherdesses who lounge on sunny hillsides all day, constructing love poems and enjoying nature's bounty. As you can see, it's a bit unrealistic and silly, but it has always been a popular genre with poets and playwrights.
As You Like It both mocks and is itself a pastoral play. Though the shepherds themselves are minor (and comic) characters, their actions influence the changes and lives of the main characters. Additionally, the main characters are all of noble birth, coming from the corrupt city, where their fortunes have gone sour, to the grace of the forgiving countryside. Only in the natural world can these nobles experience the freedoms and opportunities denied to them at court: Rosalind can woo and marry Orlando, the banished Duke Senior makes his own court in the forest, where he and his merry men feast and make music and enjoy the bounty of nature, etc.
Additionally, the experiences they have in the natural world fundamentally changes each of the characters for better. Duke Frederick has an encounter that causes him to give up his ill-gotten power and join a monastery. Duke Senior discovers the joys of a simple life in the wood after his brother banished him there. Oliver has an epiphany and chooses to leave the court and live with Celia in Arden, herding sheep. These examples demonstrate the theme of nature as a healing and nurturing force. At the same time, the improbability of some of these plots mocks the very same theme, and the pastoral genre as a whole.