Oscar Wilde was imprisoned for (basically) being gay. But what isn't so well known is that, in Victorian Britain, you could actually get away with being fairly openly gay without getting into trouble with the law - it was only if you actually got caught doing something definitely gay, e.g. picking up a rent boy, that you'd get into trouble. And on the whole, the police didn't really consider it worth their effort to chase people who weren't really causing trouble.
The reason Wilde got done was that the borderline-insane Marquess of Queensbury heard that Wilde was fucking Queensbury Jr and went to Wilde's favourite hotel with the intent of beating the living shit out of him. Upon discovering Wilde had left, Queensbury left a visiting card with the message, "To Oscar Wilde, Posing Somdomite." Wilde attempted to sue Queensbury for libel.
The problem here was that in order to defend himself, Queensbury had to prove that Wilde was a "Somdomite." Which was pretty easy, as Wilde was pretty well known for being a big fat gay, and a whole parade of witnesses were produced. So Wilde not only lost his case, but put himself in a position where it was beyond reasonable doubt that he was guilty of illegal acts. So he went down for two years, and not in the way he'd have liked.