You can say the same about a lot of other things, e.g. being divorced, being in a same-sex relationship, being adopted: somebody out there will judge you negatively for it, but fearing their judgement is part of what gives it power.
The stigma for mental issues is still a lot more severe than sexuality etc, and the court knows they can do it without consequences. Mental health issues are often viewed as a moral failing or a weakness of a person who can't get their life sorted out, a bit like how people are judged for laziness. Very easy to stick to a "criminal" without anyone batting an eye.
If the judge instead said "this guy's not that bad, he's just gay" it wouldn't go over so well.
The stigma for mental issues is still a lot more severe than sexuality etc, and the court knows they can do it without consequences. Mental health issues are often viewed as a moral failing or a weakness of a person who can't get their life sorted out, a bit like how people are judged for laziness. Very easy to stick to a "criminal" without anyone batting an eye.
If the judge instead said "this guy's not that bad, he's just gay" it wouldn't go over so well.