Feste (in some versions of the text he's called The Clown) serves the lady Olivia as her Fool. In Shakespeare's day, a Fool was someone that a well-to-do person might keep around to amuse them with their wit. And it is this "wit" that Shakespeare uses the character of Feste for in Twelfth Night.
The first time Feste appears on stage, he sets the tone for his witty observations of the other characters in the play. His lady, Olivia, is in mourning for her brother. Some might call her mourning extreme, since she has vowed to close herself off from human interaction for seven years.
Feste arrives on the scene (after having been absent for some time) to declare that he is not the "fool," but rather Olivia is -- and that he can prove it. The upshot of his proof is that, if she believes that her brother has gone to Heaven (where everyone desires to ultimately end up), why in the world is she sad about that? She should be happy. So, she is a fool.
It is common for the Fools in Shakespeare's plays to stand outside the action, observing and commenting on the follies and tribulations of the other characters, but never becoming too involved in the circumstances that drive the plot. And this can definitely be said about Feste.
Viola comments that Feste is "wise enough to play the fool".
He was originally employed by Olivia's father and she has kept him on. Fools had a certain license to tell the true. They could do this because they were fools and who would believe a fool? Others, of course, could see the truth of the fool's statements but usually the one the criticism was aimed at was oblivious to it.
There are different types of fools in Shakespeare. They could be clowns and buffoons, like Dogberry or Bottom or they could be witty and clever like Feste who is the forerunner of Lear's fool. These fools literally lived by their wits as does Feste.
In Olivia's household, Feste and by association, Sir Toby, represent the fading past. Malvolio, is another type of fool who represents the present. He is humorless. Shakespeare shows the battle between these men. In the end, neither wins.