Being one of the two alicorn ponies in Equestria, Princess Celestia possesses magic far beyond normal unicorn ponies. She is able to control the sun and the daytime sky, bringing them out each day and then moving them away to make room for the night. In Princess Luna's absence, she was responsible for moving the moon as well.
One thousand years ago
Legend states that one thousand years ago, the day and night cycle of Equestria was ruled by two sisters: Luna, the younger, who brought the night, and Celestia, who brought the day. However, Luna grew jealous of her sister: the ponies of Equestria all enjoyed and loved Celestia's daylight, but were all asleep at night. No one was awake to appreciate the beautiful night she had worked so hard to create. Eventually, this jealousy and bitterness drove Luna to become Nightmare Moon, and prevent Celestia from bringing forth the sun. She intended to keep Equestria in eternal night. Her older sister, with great sadness and regret, stopped Nightmare Moon by using the Elements of Harmony, and imprisoned her within the moon. Henceforth she became known as the Mare in the Moon and knowledge of her slowly drifted to the area of myths.
Nightmare Moon's escape
A thousand years passed under Princess Celestia's rule, until the night of the Summer Sun Celebration, held in honor of Princess Celestia and the longest day in Equestria. Shortly before the celebration, Celestia's student, Twilight Sparkle informed her of the imminent return of Nightmare Moon. Celestia responded by sending Twilight Sparkle to Ponyville to oversee an upcoming party, and make some friends. The princess knew Twilight had the power to stop Nightmare Moon, but the young unicorn needed to understand friendship in order to wield the Elements of Harmony. Nightmare Moon escaped as prophesied, and appeared in place of Princess Celestia at the celebration.
After Nightmare Moon was transformed back to her former self, Princess Celestia offered forgiveness to her little sister, and proposed they rule together. With Equestria back under both sisters' rule, Princess Celestia allowed her student to stay in Ponyville with her friends, instructing her to study the magic of friendship and report in about what she's learned about friendship periodically.
Some of this page is derived from the Friendship is Magic Wiki.The original article is at Princess_Celestia.