It's hard to say, really. For the most part some programmer comes across something that they perceive as ineffecient or that they see a need for and writes the thing.
Programming is a process frought with frustration and errors.
It's difficult, especially considering most significant programs today require concurrency, web deployment, database back ends, and decent interfaces. Errors don't just creep in - they flood over the bulwarks and invade. As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.