The primary cause of chorioamnionitis is a bacterial infection, most commonly caused by organisms such as Group B Streptococcus, Escherichia coli, and anaerobic bacteria. The risk factors include prolonged rupture of membranes, multiple vaginal examinations during labor, and preterm labor.