In 1993, when the book was published, neither courts nor dissociative identity disorder (DID) worked as they do today. DID was considered in 2008 to be
one of the most controversial psychiatric disorders, with no clear consensus on diagnostic criteria or treatment.
I'm no law expert, so I can't address the realism (or lack-there-of) of this scene, where a single expert classifies Aaron as having DID, and the court believes it. However, going by the movie's plot, the jury has, as evidence,
- Molly Arrington, the psychiatrist examining Aaron, is convinced that he suffers from multiple personality disorder caused by years of abuse at the hands of his father
- Vail slowly sets up a confrontation in court by dropping hints about the Archbishop's pedophilia, as well as Stampler's multiple personalities.
- After Venable questions him harshly during cross-examination, Stampler turns into "Roy" in open court and attacks her, threatening to snap her neck if anyone comes near him. He is subdued by courthouse marshals and rushed back to his holding cell.
The entire trial was set up by Vail to slowly turn the jury's opinion towards insanity.
Aaron is shown as a sweet scared church boy, who (unbelievably) turns into Roy, the violent sociopath. In a time where DID wasn't as well as know as it is today (which is still not that well-known), the expert's opinion and the (great) performance of Aaron makes it believable, and leads to the decision of
not guilty by reason of insanity, remanding him to a maximum security mental hospital.