Characters in works of fiction can have a number of different functions. Most stories require a hero, for example, who the reader can side with and emotionally invest in. The hero is also usually the protagonist, or main character of a story, and for every protagonist there will be an antagonist. The protagonist and antagonist always want very different things. One, for example, may want to save the world and the other to destroy it. Or, one may want to catch the killer and the other is the killer who wants to escape. In most stories, the dramatic tension will stem mainly from this conflict between the protagonist and the antagonist.
In some stories, characters are symbolic and symbolize an idea outside of the story. For example, Aslan in The Lion, The Witch and The Wardrobe symbolizes Jesus Christ or Christianity itself. In Of Mice and Men, the character of Crooks symbolizes the racism that was prevalent in the 1930s. Symbolic characters are a good way for the author to communicate his or her thoughts about a big idea.
A character also sometimes serves an important function as a foil character. A foil character's function is to emphasize by contrast a different trait in another character. For example, in The Simpsons, Bart and Lisa are foil characters for one another because Bart's poor behavior emphasizes (by contrast) Lisa's good behavior, and vice versa.