I have self published two books for children. Even if I hadn’t needed illustrations, I would still have needed to pay for an editor, cover designer, someone to do the layout, and print copies of my book. I know they can be done by authors, however I know I don’t have the skills for design, and anything I come up with won’t look as good as a professional can make it. And then there’s promotion!
Essentially, publishing a book costs money.