Originally, Twilight Sparkle was sketched by Lauren Faust with the color scheme of a 1st Generation unicorn, simply named "Twilight". However over time, she adapted a color scheme similar to a 3rd Generation Earth Pony named "Twilight Twinkle", and in the original script to Friendship is Magic, "Twilight Twinkle" was originally supposed to be her name.
Twilight Sparkle also shares several personality traits to another 1st Generation Pegasus, Wind Whistler. However, Twilight was given a much more thoroughly developed character as more episodes aired, and quickly became her own character outside of the influence of past generations.
Twilight Sparkle is the center of a the group of six friends who all symbolize one of the Elements of Harmony (nicknamed the "mane six") and the faithful protege of Princess Celestia, the ruler of Equestria. Her special talent (designated by her cutie mark) is magic, which is also the Element of Harmony she represents. She's also been praised as the most talented unicorn in Equestria, for not only the raw power she can exert when necessary, but for the versatile skills she's accumulated over time.
In her time in Ponyville, she's often evaluating the situations she and her friends find themselves in, reporting her studies in the magic of friendship to her mentor, Princess Celestia. Learning meaningful lessons on how to be a good friend firsthand, she's learned how to build a strong relationship with each of her friends, despite occasional shortcomings or challenges they encounter.
In many situations, she's often found herself to be the voice of reason and a natural leader in times of uncertainty, due to her natural organization skills. Despite this, she easily becomes very anxious when her plans fail when executed. In one case, making her become delusional. And under stress she can become extremely obsessive, particularly with organization.
Cutie Mark Chronicles
As a young filly living in Equestria's capital city Canterlot, she became inspired to study magic when she saw Princess Celestia raise the sun at the Summer Sun Celebration. Investing her free time in studying, her parents eventually enrolled her into "Celetia's School for Gifted Unicorns". At her entrance exam, she was tasked with hatching a baby dragon egg. Failing her first attempt to hatch it, distracted with worry as her examiners judged her performance, she decided to give up. However before the test ended, a Sonic Rainboom miraculously detonated outside, triggering a powerful surge in her untapped magic in her. Levitating off the ground and her eyes glowing in a trace, she not only hatched the egg, but grew it into a full grown dragon, turned her parents into house plants and lifting her examiners into the air.
Princess Celestia then intervened, her attention being caught by the dragon's head bursting through the roof, and undid Twilight's magic and calmed her down. Impressed by her raw ability, Celestia offer the young filly to be her protege, much to her surprise. Not only that, but she also pointed out that Twilight now had her cutie mark, much excited jumping around ensued.
Friendship is Magic Part 1 & 2
By the time the pilot episode aired in the continuity, Twilight lived in a literal "Ivory Tower" library in Canterlot. She also lived with the baby dragon she hatched, Spike, who acted as her personal assistant. Living here, she showed little interest in making friends. Not exhibiting any anti-social behavior, it seemed she was simply more fixated on her studies.
After uncovering a prophecy that depicted the renegade ruler of the night, Nightmare Moon, to return on the upcoming Summer Sun Celebration, she wrote the Princess to warn her, using Spike's fiery breath to teleport the message. In reply, Twilight was assigned to oversee the celebration in Ponyville and make some friends. Hesitant to comply, she and Spike went to Ponyville as asked, although Twilight was more fixated on reading up on the magic originally used to beat Nightmare Moon, the "Elements of Harmony".
As she oversaw the event, she inadvertently made friends with the ponies in charge of specific operations, despite little input on her part. When she returned to the library she was assigned to stay at, she was startled to find a surprise party for her. Orchestrated by the free spirited socialite Pinkie Pie, Twilight was greeted by all the friends she's made over the day and welcomed to Ponyville by others.
Twilight waited the party out in her bedroom after loosing her patience at her lack of time to study, and joined the crowd to see Princess Celestia raise the sun at Town Hall. However, unlike civilians, she wasn't surprised to find their ruler missing, against her hopes she was wrong. As Nightmare Moon appeared instead to inaugurate her return, she was the only one to know her by name, and her malevolent plans to rule Equestria under darkness.
In the wake of the panic, she rushed back to her library where her friends found followed, understanding she's the only pony who knows what's going on. She found a book outlining vague details of the Elements of Harmony, which would lead her into the ominous Everfree Forest where she would find them. Applejack, along with the others unanimously insisted to help her, refusing to let her risk her life alone. As they traveled through the forest, Nightmare Moon stalked each of them in the form of a starry blue entity, pitting them against challenges only wielders of the Elements of Harmony could overcome.
Besting every one of their challenges, they eventually find their way to the ruins they were seeking. Wanting time to herself to figure out how to activate them, her friends left her alone. Then, Nightmare Moon appeared to confront her. Failing to detonate the stone artifacts of the elements, she feared they didn't work. However, as her friends showed up to help her, she understood that the Elements were alive in them, leaving her to be the one Element left as a mystery; Magic.
All six ponies magically aligned in the air, the Elements of Harmony physically appeared on all of Twilight's friend in form of a necklace resembling their cutie mark. Twilight's element being a crown, and a rainbow erupts from the bearers of the Elements and casts down Nightmare Moon, cutting through her wicked form and reverting her back to her original body, as Princess Luna, Celestia's younger sister.
The next day in Ponyville, Pinkie Pie throws a party to celebrate Luna being redeemed from her evil form and being reunited with her sister. Princess Celestia then gives Twilight a new topic to study so she could stay in Ponyville; to study the magic of friendship and report back to her whenever she learns a meaningful friendship lesson. Twilight agrees to her offer gratefully, beginning her new life in Ponyville with her new friends.
Magical Mystery Cure
Due to accidentally speaking out the magic words from an unfinished spell from Star Swirled the Bearded’s book she jumbled her best friends’ cutie marks which caused massive mayhem. She founded a way by using her friends' compassion to help a friend in need. When she returned their original cutie marks and identities, save the town and finish the spell, The elements of harmony blasted her and she was reborn into an alicorn princess. The next day all of Equestria beholden her coronation as Princess Twilight Sparkle.