Feste has a couple of different roles in the play. One role is represented by his name, which can be seen as a derivative for the word festival. Shakespeare wrote the play Twelfth Night for an Epiphany celebration, and the entire play is essentially a festival. The holiday known as Epiphany fell on the twelfth day after Christmas and marked the arrival of the Three Wise Men who came bearing gifts to baby Jesus. While one might expect an Epiphany celebration to be similar to the rest of Christmas festivities, in Elizabethan times, the holiday was known to be "absolutely secular and even quite bawdy"; it was also a "time of masques, revels, defiance of authority, and general foolishness," all of which are details mirrored in the actions and themes in the play ("Shakespeare's Twelfth Night"). Hence, as a court jester, one of Feste's roles is to represent the merriment and foolery characteristic of the holiday.
However, he also serves an even greater function. Even though through his fooling he participates in the play's festivities, he actually also remains outside of the play's society with the purpose of serving as a moral judge (eNotes, Twelfth Night Essays: "Feste and Fabian: Plots and Complots"). One element that characterizes him as standing outside of the play's society is that we learn in the very beginning of the fifth scene that he is an itinerant court jester, meaning that he does not really belong to one household but rather travels about from household to household within a certain court. We know he is an itinerant fool because when we first meet him, Maria scolds him for his absence, saying, "My lady will hang thee for thy absence" (I.v.3). In addition, we also learn that he not only associates with Olivia's house but often goes to Duke Orsino's house as well, showing us that he does not really belong to one specific household as a servant, and since he does not belong to a specific household, it shows us that he is also not a part of the play's society, but rather remains outside of it.
Remaining outside of the play's society is central to his characterization because it also puts him in a position to be the play's moral judge. We also see him playing the role of moral judge in this very first scene in which we meet him when we see him assert that Olivia is the true fool rather than himself. When Olivia commands, "Take the fool away!," Feste turns the tables and declares that Olivia should be taken away because she is the real fool for allowing herself to mourn so excessively over a brother's soul who is in heaven, as we see in his lines, "The more fool, madonna, to mourn for your brother's soul being in heaven. Take away the fool, gentleman" (I.v.33, 64-65). Feste also very wisely notes the insincerity of Duke Orsino's proclaimed love for Olivia and calls him fickle by asserting that his mind is a "very opal," meaning a gemstone that changes color easily (II.iv.80).