The story is as follows: After the events of Lesson Zero, somepony died as a result of Twilight’s want it need it spell, Princess Celestia was left with no choice but to arrest Twilight, on charges of ponyslaughter, endangering other lives, misuse of magic, mass destruction, brainwashing, disturbing the peace, multiple counts of assault and serious injury, and filly abuse. Twilight eventually accepted a plea deal offer from the prosecutor, who took into consideration the fact that She was an element of harmony and this was her first offense. Twilight was sentenced to 5 years of incarceration with eligibility for parole after 3 years.
EDIT: On a side note, i am happy to report that this is the 1000th picture to have the “prison outfit” tag here on Derpibooru. :3