Somerset points out that if John were to use the insanity plea as a defense strategy, the prosecution could use the fact that he announced this beforehand to negotiate a deal as proof in court.
In particular, the prosecution could argue that an insane man would not have suggested such a deal and John's claim of insanity is simply a ruse of his defense lawyers to keep him out of prison. Unlike the hot-headed Mills, who immediately agrees to the deal when confronted with the prospect that John might escape his sentence, Somerset, at his usual judicious self, recognizes that John's threat is ultimately empty and will very likely not hold up in a court. Somerset only agrees after the lawyer appeals to his compassion for the victims. This clearly shows another difference between the two detectives: While Mills is motivated by seeing the bad guy punished, Somerset is driven by compassion for the victims.
Only in the conclusion of the movie, Mills is forced to painfully realize that whether or not the perpetrator is punished ultimately won't change anything for the victim.