Elsa remembered when Prince Hans returned to seek his revenge. She and the guards had let him in, thinking he was a sick beggar only to realize it was the banished prince in disguise.

"Because you had to humiliate me in front of everyone, my brothers have stripped me of my title." said the angry former prince, "This is no longer about taking the throne; this is about revenge."

When Hans grabbed Anna, holding a knife up against her neck, Elsa panicked and threw her ice powers at him, striking his head, knocking him unconscious. She could've let him die, after all, he DID try to harm her sister, but deep down, Elsa felt it wasn't right. Even if he was a cold hearted monster, leaving him to freeze to death would only make things worse.

Elsa took Hans to the trolls at the Valley of the Living Rock. He was already cold and a strip of his hair had already turned white. Pappie put his hand on Hans' head, realizing there was more wrong with it than being frozen.

"His mind is plagued with memories of fear and hate. I will take away both of his ailments. He will only have memories of love, but while his head may be cured, his heart will not be easily persuaded."

After Pappie had cleared Hans' head, elsa was left with a tough dilemma: what to do with him. She couldn't send him back home in fear his memories would come back and she couldn't lock him up in the dungeon if he had no memories of any crimes he had commited. There was only ONE way she could think of to deal with him: make him a "guest" of the Arendelle Castle and keep the doors closed.