Olaf is a snowman built by Elsa. He is based on a similar snowman built by Elsa and her sister, Anna, when they were both young. Though she was unaware of it, Elsa imbued Olaf with life, and the snowman proved instrumental in Anna's quest to find her sister.
In his first incarnation, Olaf was not yet alive and required Elsa's assistance to "move" and "speak".
Olaf was built on the night of the accident that would separate Elsa and Anna for thirteen years. At the time, Olaf was not yet sentient, and Elsa would simulate the snowman's actions and voice, creating his signature greeting: "Hi, I'm Olaf, and I like warm hugs". Anna loved the snowman she had built with her sister, and the three of them skated inside the Great Hall, propelled by Elsa's magic. However, after Anna was struck by Elsa's magic, Olaf toppled as a result of ice spreading across the room.
Elsa recreated her beloved snowman.
After her powers were revealed following her coronation, Elsa fled Arendelle. Due to the long years of concealment, Elsa did not mind being away from everyone else and seized the opportunity to experiment with her abilities. During this moment of catharsis, Elsa recreated her beloved snowman, unknowingly imbuing him with life. After some time, Olaf would make his way from the North Mountain to a frozen forest that glittered from light refracting off of the ice crystals.
The snowman soon happened upon two traveling individuals, Anna and Kristoff, and a reindeer, Sven. Overhearing Anna's statements about the ice forest's beauty, Olaf voiced his agreement but interjected that it would be better with a dash of color. Not realizing that his sentience was startling, Olaf was subjected to an instinctual kick from Anna and lost his head. Despite this, Olaf remained cheerful and, having landed in his arms, greeted Kristoff. However, the ice harvester was similarly disturbed by Olaf and tossed the head back to Anna. Olaf's head continued to exchange hands in this manner until Anna threw it back at his body, though it landed upside down.
As his dream was to experience the summer heat, Olaf agreed to lead Anna, Kristoff, and Sven to Elsa.
When Olaf wondered at why Anna and Kristoff were hanging from the earth, Anna grew sympathetic and helped the snowman rearrange his head and presented him with a carrot nose. Grateful for the kindness, Olaf proceeded to introduce himself. Upon hearing Olaf's name, Anna remembered the snowman she and Elsa had built together. Realizing Elsa must have rebuilt Olaf, Anna asked the snowman if he could lead them to Elsa and have her restore summer. To Anna and Kristoff's surprise, Olaf remarked that it was his dream to experience summer, and happily led them onward to Elsa.