The girls were dancing in the woods because they were participating in superstitious rituals with Parris' Barbadian slave, Tituba. In Act 1, Abigail says that, as they danced, "Tituba conjured Ruth's sisters to come out of the grave." Ruth's mother, Mrs. Ann Putnam, has lost seven babies within a day of their births, and she is convinced that witchcraft had something to do with it. She fears that her only surviving child, Ruth, is becoming ill, so she "thought to send her to [...] Tituba" because "Tituba knows how to speak to the dead [...]." Now that Ruth has been struck silent, her mother fears that some dark power has a grip on her too.
However, there is one other reason the girls were dancing in the woods, and it is revealed by Betty Parris. She cries, "You drank blood, Abby! [....] You drank a charm to kill John Proctor's wife! You drank a charm to kill Goody Proctor!" This, murder, is a much more serious crime. And so Abigail threatens the girls that if they "breathe a word, or the edge of a word" about the charm, she will come to them in the middle of the night and kill them. Abigail does, in fact, want Elizabeth Proctor out of the way so that she can be with John Proctor, her former employer with whom she had an affair seven months prior.
Both conjuring spirits and drinking charms to murder someone would be considered sins to this community, and their legal laws were very much based on religious principle. If something were considered sinful, it would also be considered illegal. It's not so much the dancing that was the problem as the fact that dancing is associated with superstitious rituals like the ones in which the girls were participating. Reverend Parris chastises Mrs. Putnam when he learns that she put Ruth and Tituba up to conjuring her dead children because "it is a formidable sin to conjure up the dead!" For obvious reasons, drinking a charm to murder some innocent woman is also a terrible sin, and this is why Abigail is so anxious to keep it quiet.