I bet you just did nothing wrong, but the Emperor saw you where the awesome, stalwart Hero needed to solve all his problems. But he can't be seen associating with you because of nonsensical social standing stuff. So he lets them pick you up and secretly visits you whilst in prison. Perfect, Mon Capitan!