Why it is hard isn't that complicated, if you have ever watched someone struggle. Learning to write software is easy. Learning to debug the software you write is hard, and takes some time. Learning to write maintainable software is much harder still.<p>The problem of course is that the only way you will get the software to work is if you can debug it. This requires learning a new way of thinking which is why it is hard. That takes months often. Then you can go from writing very trivial programs that work to somewhat less trivial programs that work.<p>The problem beyond this though is that as hard as debugging is, learning to write maintainable code is even harder. It requires learning to think about the way you will be thinking (later) about the way you will be debugging the software. This can only come slowly from experience.
Programming is a craft, you can always improve it with more experience and hours of practice. I think what makes it interesting is that new languages and environments emerge and programmers have to learn to apply their existing knowledge while continuously unlearning parts of their craft.<p>I've been programming for almost 30 years now and even within the relatively constrained world of low-level C programming I still learn new skills all the time. I would say, though, that it took me a good 2 or 3 years of regular practice to get to the point where I avoid most common mistakes and develop debugging skills to find the mistakes I still make.