Plain and simple: Peer Pressure. They needed to be part of this social activity which is easy to get caught up in with the rhythmic "beating" of their voices like drums as they sing and dance around the fire. Remember, they have been on the outside in their small group for quite some time, and it is a wonderful feeling to be part of something larger--to belong and not be targeted. There is safety in numbers. It is also very primitive in bonding and preparing for the hunt or celebrating the victory of a hunt, which is the case here. They were reenacting the hunt for the boar, celebrating their success, cooking the meat, and eating. Maybe moreso than anything else, Ralph and Piggy were hungry for good, hot, nourishing protein.
Because of the power of a group and the need to be accepted--parents and teachers usually bag it all together and call it peer pressure, but it's probably much bigger than that. Humans have a natural need to be accepted and a drive to be a part of something bigger; it's not natural to be alone with anything. Ralph and Piggy are both standing outside of the group and realize they will probably only get farther away from the social circle Jack has created. The chance to join the dance and chant is a rare opportunity for these two boys to become a part of that larger group again; something they won't pass up.
- Piggy and Ralph join the dance because of Peer Pressure. They have been isolated from a social group for quite some time, so the desire and wonderful feeling of “fitting in” lured them. Moreover, they probably felt that the longer they stood outside of the social circle, they more distant they will be from the group. Their chance to join the dancing and chanting is a rare opportunity for the boys to be part of a big group again—it is an opportunity that is hard to avoid.