Learning to code is hard, and everyone's specific struggle is unique. The key issue though is why do they fail to learn, and that answer is the same for everyone that fails: they give up.
All kinds of mental talents can be helpful for learning to code, but tenacity is probably the most important. Better learning materials can be great, and they're getting better all the time, but they are still no substitute to an unshakable commitment to being a developer.
For my 12th birthday in about 1980, my grandparents heard I liked computers and bought me a college level textbook on microprocessors. I didn't understand a word of it when I first read it really. But I did read it, and re-read it, for a couple of years. And it's one of the key reasons I wasn't afraid of doing assembly language a while later when I got my first computer. The book was a terrible way to learn, and it was completely at the wrong skill level for me. But I was really into it and made up for my lack of capability with a tremendous commitment and huge amount of time, slurping up every bit of information on computers I could find.
This is an incredible answer - persistence is absolutely key. What I'm exploring is how to make persistence efficient. How can we make it so that people don't have to spend that horribly inefficient time reading a textbook like that?