To maintain a high level of performance as a software engineer, you need to be highly motivated. The relevant technologies are constantly changing, and it requires signicant effort to stay up-to-date. Some of the most successful engineers are the ones who are intrinsically motivated by the challenges of solving difficult software problems.
This question is usually asked to help determine whether you have traits that are desirable for somebody in this role. It can also provide insight into your personality and help determine whether you are a cultural fit for both the company and the team.
There really isn't a right or wrong answer with this one. Just be aware that you should try to position your answer so that it aligns with what you think might be desirable traits for this particular position. For example, you could describe a situation where you were motivated by a challenge, and then created a solution.
Any response that indicates that you are motivated by material factors will be viewed negatively. You want to demonstrate that you are motivated intrinsically by the challenges that you'd typically face in this particular position.
Why is it Important to Hire Software Engineers Who Will Code for Free?