To what extent can we say that As You Like It is a happy and optimistic play?
Only to some extent can we say that As You Like It is a "happy" play. The biggest example of this is the character of Jaques. He is a melancholic, refusing to join in with the happiness of the rest of the inhabitants of the Forest of Arden, but instead wanting to reflect miserably on the woe of the world and even try his hand at punishing sinners.
At the end of the play, when the god of marriage, Hymen, comes on stage to marry four couples: Rosalind and Orlando, Celia and Oliver, Touchstone and Audrey, and Phoebe and Silvius, he refuses to help them celebrate their nuptials. Instead he ends the play on a sour note, going to find the Duke Frederick who has become a hermit and to be his companion instead.
But despite this, Jaques is a welcome presence in the play, tempering the sweetness of the romance that otherwise might have seemed too saccharine.