Character Functions
Many critics of Olaf's character cite that Olaf is unnecessary to the plot and a distraction from the main theme of the film. I disagree with this, because I find that Olaf performs several necessary functions in Frozen.
Comic Relief*
For certain, Olaf is comic relief for a film that could otherwise be far too sad and dark. He comes off at first as merely a carefree, ADHD dreamer, happily trotting his way through danger and even blithely putting himself back together without a worry in the world. Audiences are meant to laugh at him, to consider him outlandish and silly; he provides an excellent counterbalance to Elsa's character arc, as well as the drama surrounding the future of Arendelle.
(* But wait, there's more on Olaf's supposed role as comic relief here!)
Living Proof of the Nature of Elsa's Gifts
Olaf is far more than merely a jester; he's also a living sign that Elsa's powers are not inherently evil. She created him, after all! Her abilities in ice and snow are thus proven to be more marvelous and potentially helpful than anyone imagined. Olaf's presence demonstrates to Elsa that she has yet to tap into the wondrous expanses of her gift--and he also wordlessly reminds her that it IS a gift, no matter what others may say or do.
Exemplifying Unconditional Love
During the film, Olaf demonstrates what unconditional love really is. When he stokes the fire to warm Anna's chilled body, Olaf begins to melt, but he doesn't worry; instead, he uses this as a teachable moment, saying, "Some people are worth melting for." He proves to Anna that love is not all fluffy nice feelings and grandiose words/gestures; love is sacrifice, too, and choosing another person's benefit over your own. This is a reminder she needs more than ever, especially after Hans (the man she thought loved her) abandons her to die of cold.
Challenging Our Ideas of "Realistic Goals"
Olaf is easily brushed off as a silly character, too innocent for his own good--but his innocence also lends itself to wisdom. Even though he doesn't know what heat is till he feels fire, he is wise enough to know he will be better for experiencing it. All he looks for is the experience of summer and heat, no matter how brief. He is an explorer at heart; he was created from childhood wonder, and so he projects that wonder and curiosity forward as he lives his life. We often worry too much over the future, whether it will change us or inconvenience us; Olaf eagerly awaits being changed and inconvenienced, because he longs to learn and have new experiences.