Story of origin of Saptamatrikas, the seven divine mother goddesses in Hinduism, is found in the
Mahabharata, Varaha Purana and Kurma Purana. The popular story is that the
Saptamatrikas appeared to defeat the thousands of Anadhakas that were born from
the blood of demon Andhaka.
Andhaka was actually the third son of Shiva. Lord Shiva
injured demon Andhaka when he tried to take away Goddess Parvati. Andhaka had
received a boon that a single drop of blood spilled from his body will create
thousands of Andhakas. So when Shiva injured Andhaka thousands of Andhakas
appeared from the blood split.
To defeat the Andhakas, Shiva created Yogeshwari and the
other gods created Saptamatrikas.
They then fought and defeated the Andhakas.