The affair is the main reason why the witch hunt began. Abigail very much wanted to be with John Proctor. However, girls were to remain pure. Certainly, adultery was forbidden but for a young girl to have an affair with a married man would have been the most horrible crime of all.
Although we never really get the details of the affair, we know that Elizabeth and John were having troubles in their marriage. John succumbs to his desires albeit momentarily. When he realizes what he's done and tells Abigail the affair is over, she is scorned, jealous and hateful. She has to find a way to get back at him. How does she do this?
When the group of girls is caught in the woods in what is perceived as acts of evil (dancing, singing, laughing...how could they??), the sensible people think they must have been overtaken by spirits. Perhaps in an attempt to hide the truth, the girls continue this thinking. Eventually, women throughout the town are accused of being witches. John's wife is among them.
It seems that this is in keeping with the common thinking: if I can't have him, you can't either.
Proctor's affair with Abigail is an important plot device. Ordinarily for the Puritans, adultery was a serious offense. It was considered to be not only a sin but as a criminal act, for which the accused could be whipped or otherwise publicly humiliated or even executed. (See the article at the Washington Post link below.)
However, the judges overlook Proctor's true confession of a crime he really has committed and hound him to confess to a false accusation. And they completely ignore the fact that the person who has so falsely accused him is the partner in his adultery. By putting the two crimes in comparison, Anderson is emphasizing how rabid and arbitrary the witch hunts had become.
Visit the links below for more information.
Not much is really revealed about the affair itself. Miller seems to be more concerned with the consequences the affair had on the witchcraft trials. Elizabeth implies that it began when she was sick for a long time and "cold" to her husband. Abigail still wants to be with John Proctor and that may be one of the reasons she puts the needle in the poppet which leads to Elizabeth's arrest. John Proctor seems more embarrassed by the affair but is willing to reveal it in order to save his wife. Ironically, this leads to John Proctor's arrest and things to not work out according to Abigail's plan.