The judge isn't releasing him, the clinical people are. They're saying he was mentally ill at the time but is now cured of his dangerousness.
The pervasive fear in the potential of a person to do harm is highly illogical. It's downright phobic. This is largely why US has one of the largest per capita incarceration rates in the world, and some of the toughest sentences.
A person who drinks and drives is potentially more dangerous than someone mentally ill who killed people. So is a soldier, prison guard or policeman with a gun and a license to kill. So are the people who allow toxins into the food, air, water and consumer products. And people who damage the environment. And people who text while driving. And so on.
Fearing harm from the mentally ill or the poor or anyone who looks scary or anyone with a record is one of the most twisted of phobias people drag around. It foments a perverted sense of justice, merely because the person "seems" dangerous. Judges and juries run with this logic all the time and throw the book at people who may either be actually innocent or not even aware of what they have done.
But that's how it works in the US, because justice is highly discretionary, as it is with fairness or the ability to connect cause and effect due this highly probabilistic notion we might call "dangerousness".
What is the probability that this person will re-offend? Answer: who knows, if not the medical personnel who evaluated him? Why try to second guess them? Ah: it's done out of a sense of righteous indignation. Which is what, if not sheer irrationality?
Answer: that's all it is.