I wrote this answer for thi question on Quora.com and thought it could be helpful to share as a post.
The market size of the Children's Book Publishing industry is expected to increase by 2.2% in 2022. In the US, it grew faster than the economy overall (source: IBISWorld - Industry Market Research, Reports, and Statistics). So, the reason for the affirmation "There is no money in writing children's books?" could not be justified by the sector's performance.
I'll share my experience as an author and illustrator. So far, I've published 3 picture books as an author & illustrator with Apila, a Spanish publisher.
My first book with them won their annual contest. The winner gets €4000.00 as an advance (equivalent to 10% of the first batch o books printed, an industry average). They get an around 300book submissions for each contest. So, here we have the first reason: Many people are making books and trying to publish them. So, only phew ideas will get to see the light of the day.
What’s next. I finish my book, and it goes to market. The book was well received and had a second print after roughly one year of its launch. I get more 10% of the second batch (hooray). If I were "only" the author, I would get 5% as the other 5% would go for the illustrator. Here comes the second reason there is less money "writing" children's books.
The third reason would be that new books will compete with old classics. My first book, "Un Arbol" (a tree), ranks between the top 10 up to the top 100 on the "counting books for infants and toddlers" of amazon in Spain. And there's always some variation of the "very hungry caterpillar" around it. It can be a version of the book with magnets, hardcover, paperback, Spanish version, etc. So, a new book won't compete only with the books launched this year but with all the books published in previous years that are still in the market.
Also, there's a long tail effect: the best seller outsells the books that are down the tail. And my last consideration: there are also many books based on TV characters (Pepa pig, Pocoyo, etc.) which will take sales of more "authorial" works.
So, unless you make a bestseller, it's tough to make good money, or any money at all, writing children's books. In my case, I can say the book paid off my efforts, but I haven't made proper money with it so far. Hopefully, I'll keep getting royalties on the long run.