Technically he was never in jail - he was given the choice between imprisonment (homosexuality was a criminal offense back then) or chemical castration. He plead guilty to "gross indecency" and was ostracized by the scientific community until his death.
The British government issued a formal apology and overturned his conviction around a decade ago.