The IEP article on Descartes states that
Descartes states that his purpose in showing that the human mind or soul is really distinct from the body is to refute those “irreligious people” who only have faith in mathematics and will not believe in the soul's immortality without a mathematical demonstration of it.
And yet at the time (Early 17th century Europe) there would have been few if any openly irreligious or atheist philosophers. The Church still dominated European intellectual life, and people like Galileo got prosecuted for less radical transgressions than being atheist or declaring that men didn't have souls.
Moreover, literalist interpretations of one or the other monotheisms were so dominant and influential, that the idea that people had immaterial souls would have been so obvious as to be self-evident. The Enlightenment, with its questioning of existing dogmas, wouldn't start for a few more decades.
So who was Descartes exactly trying to refute when he came up with his cogito? Were there any openly materialist/atheist philosophers in his day?