Why do vanity journals exist? I'm confused about the existence of vanity journals. My impression is that they often charge significant sums of money yet provide no peer review, editing, etc.

If I want to claim I published something to stoke my ego, why wouldn't I just create my own "Journal of articles that were totally peer-reviewed" and "publish" there? In the days when things were published in print I can understand the difficulty in doing this yourself, but now surely creating a "Journal" is no harder than throwing up a quick website?
We do not call them "vanity journals."  We call them "predatory journals."  They make their money from people who do not understand how journals work.  Their customers do not know that anybody can set up their own fake journal website.  The person who is fooled by the predatory journal might be the author, or it might be the person responsible for evaluating the author's publication record.  Ego stroking is not as relevant.

They continue to exist because they are profitable.