There will always be two groups of people. One who will believe in afterlife, God, etc. (the theists) and the other who will not believe in afterlife, God, etc. (the atheists). The ideology of Cārvāka fills the atheistic position in Hinduism. However, the thing to note is that this school of thought being faulty has already lost its prominence being refuted by other theist schools of thought hundreds of years back. Hence, the number of people who believe in God, afterlife, etc. are more than the number of people who do not believe in such things.
Now the reason that such school of thought existed was simple, to delude people. Charvak was a rishi (sage), sometimes even the ideology is attributed to sage Brihaspati. In the ancient time people were doing vedic rituals, sacrifices, etc. with great effort to attain a better afterlife. To drag their attention away from heavily indulging in such kinds of act such faulty ideologies were spread.
Another reason present in the Maitri Upanishad (7.9) is that, Brihaspati, the Guru of Indra (king of heaven) introduced such a faulty ideology intentionally so that people will not perform Vedic sacrifices such as the aswamedha yanjya which award the seat of Indra in heaven. The faulty ideology will lure people of demonic nature away into lower level of existence. Hence, by not following vedic rites and sacrifices the position of Indra will remain secured.
The bottom line is, the hedonistic Cārvāka philosophy is faulty and serves the purpose of luring people away from the right path. If there are doctrines that lead people to heaven and salvation, then should not there also be doctrines that lead people to hell and damnation? How else do you think the seats in hell will get filled up?