After the incident with Anna, her parents were scared of her powers going out of control and hurting someone. The troll king warned them of dire consequences if Elsa doesn't learn to control her powers:
"Listen to me, Elsa, your power will only grow. There is beauty in it. But also great danger. You must learn to control it. Fear will be your enemy."
Her father, terrified of the idea, replies:
"No. We'll protect her. She can learn to control it. I'm sure. Until then, we'll lock the gates. We'll reduce the staff. We will limit her contact with people, and keep her powers hidden from everyone. Including Anna."
He decides that until Elsa learns to completely and safely control her powers she could be a danger to others, so he limits her contact with other people until she does. This also works to hide her powers from the general populace, who would react badly to having a royal with such a deadly, and uncontrolled, power.
Unfortunately, all this does is instill more fear into Elsa which drives her powers out of her hands. It wasn't until the movie's climax does she realize that love was the emotion that would control her powers.