1 The task is very complex, this means that there's a lot of room for human error. A well-tested and specified program will reduce this fragility and improve predictability.
2 The programmer is inexperienced, the programmer either is not a very good programmer (yet) or is using tools that he is not familiar with. The 5 hours mostly go into the learning process of the programmer, not in the task itself.
3 The task is simply something computers are not very good at, or hasn't been fully explored. For example speech recognition. The 5 hours go into exploring the domain, creating something reusable that the world could profit from.
In my opinion, it's always worth it, isn't that nice?
4 The task requires interacting with a system that was not designed with automation in mind.
For instance you have a third party GUI which you don't have source to that you have to push a button on based on what it is showing you. So you wind up having to research this, work around it, etc. Often you can use a GUI test kit to solve it temporarily, but that is going to be fragile - on the next upgrade it will likely break.
In this case automation may not be worthwhile. What you're learning is not connected with what you do. The automated solution is more fragile than the human one. The time saved is not that important.
Even if your people did implement it, depending, getting rid of the GUI might be easier said than done. I remember an Access app that I had to automate stuff around. In the end the best solution to all of the different popups that were buried in their app was to make the machine it was on remotely accessible, and have a watching process page someone if it took too long. A human would then look at the screen, and press the appropriate button.
Rule of thumb: do it manually three times before automating it. That way, you'll have a fair idea of what it is supposed to do (which is the hardest part); you know whether it's predictable enough to be automated; and an how often it will come up.
A programmer is someone who takes 5 hours to automate something that takes 5 minutes