I've heard a lot of people wondering what Starswirl the Bearded's spell was supposed to do. After all, they never really say in the episode.
First of all, I don't think we can count cutie mark scrambling as an intended effect of the spell. I've heard people ask "So it messes up ponies cutie marks and then teleports the caster away?". I think that's faulty logic. How many things fulfill half their intended purpose when half assembled? If you try to use a half assembled hairdryer it will probably electrocute you, and that's not because electrocution is half of what a hairdryer is supposed to do.
I think it is safe to assume that its intended purpose has something to do with the Elements of Harmony, seeing as how both its castings effect them. So what would Starswirl be doing with the Elements? It's stated that he doesn't understand friendship like Twilight does. Many people have headcannoned that this means he didn't go out and make friends at all. Even if that's not true I think it's reasonable to assume that he didn't have a group of friends who could activate the Elements. So I think he was trying to make a spell to artificially activate the Elements of Harmony, using magic rather than friendship. When half made it activated the energy of the Elements, but didn't direct it, so it just scrambled around. When completed it actually activated the Elements.
What does activating them do? We've seen them do two things so far. They can Imprison/banish things as well as purify/de-evil things. So, I think that when the elements were activated, and Twilight just happened to be the thing they were all pointed at, they banished her. Sending her to a metaphysical and possibly semi-timeless plane. The same as what I think happened to Nightmare Moon. I don't think she was physically on the moon (it wouldn't account for her face being on the whole thing), and she didn't seem quite "thousand years of isolation" crazy. In fact she seemed to be picking up right where she left off. Of course, this is getting into a whole different headcannon.
So Twilight got banished, and maybe she got a little purified too as kind of final step towards princesshood. Then Celestia shows up to rescue her. Why could she do that? Well, Celestia is in theory really powerful, and has experience with the elements and where they send things. Plus, she's already been keeping an eye on Twilight. So it stands to reason she saw her get blasted, or she was expecting this sort of thing to happen anyway.
So, TLDR version-
Starswirl didn't have friends who could use the elements of harmony, so he made a spell to use them artificially He couldn't finish the spell because he didn't understand friendship, and thereby the elements, well enough. Twilight finished the spell, and the elements banished her, because that's what they do. Celestia came and rescued her from wherever she got banished to.
What do you all think?