First of all, a pastoral background means that a piece of literature presents rural life in an idealized way. It's usually a fairly simple style. "As You Like It" is set in a pastoral background because it presents pastoral values, such as the good brothers vs. the evil brothers and positive viewpoints vs negative viewpoints. There are also elements of rural life involved, such as when Celia travels in disguise as a peasant girl. This causes us to examine rural life from an idealized viewpoint because Celia has lived her life as fairly privledged as she has been the daughter of a duke.
"As You Like It" is a comedy because songs and jokes are used frequently throughout the book. This makes "As You Like It" a comedy on the surface. Once we examine the work closer, we can see that it also has a pastoral background.