John has admitted to having an affair with Abby and this is why she is dismissed from their home. He reluctantly admits to this in order to show that Abby had a motive for having malicious intent towards Elizabeth. Since she has been rejected by John, he believes she is out to get Elizabeth in retaliation.
When Elizabeth comes into the courtroom, she has no idea John has confessed. John has also already stated that Elizabeth never lies. However, she does lie here in order to protect John's reputation. She says that she thought John had feelings for Abby but this turned out to be untrue. She lies to make John look like a good Christian man. When they escort Elizabeth out of the courtroom, John yells out, "She only thought to save my name!" He immediately realizes she was just trying to protect his reputation. This, of course, backfires because they now realize one of them is lying about the affair. Danforth thinks John has lied and Hale thinks Elizabeth lied to save John's name. Hale is correct but Danforth won't listen.