In his book, Dan Pink states that the three universal motivators are Autonomy, Mastery and Purpose. Agile software development, in most of it's forms, supports these three motivators intrinsically. Since Scrum is now just about the defacto standard in Agile software development, I'll use Scrum to give examples in this post.
Telling a person when, where and how to do his job will result in an automaton. And although automatons are generally good at repetetive, simple, boring tasks, when it comes to anything beyond that, they're useless. You don't want automatons on your Software Development team. Heck, you don't want them anywhere beyond a conveyor belt. Just about any role where more than simple, repetetive, boring tasks are being performed will benefit from autonomy. So instead of telling a person when, where and how to do what, why not ask him "Can you get this product in that direction?" or "Can you make this product deliver that user feature?". Trusting the person to then realize that request to the best of his abilities grants him the autonomy to do so in the way he thinks is best. The Scrum Master should make sure the person gets all the support he needs (within reason) to perform this task.
Autonomy is a good thing to have. But what if the person thinks of the best way to fulfill the request but simply doesn't have the skills or knowledge to implement it? Or what if the person has rudimentary skills but wants to become better at performing his job? Training the person and supporting him in his knowledge building endeavours has a positive effect on motivation. Not only that, it will also result in a better product. And isn't that what we were trying to achieve in the first place?
In the end, though, being good at his job and having the power to decide how to do his job himself will only get this person so far. The best way to keep people motivated is to show them the big picture. What good will his work do in the grand scheme of things? By making sure everyone knows why we're doing what we do and where the product is going, all decissions made in Autonomy and all knowledge built up in Mastery will go towards that main purpose.
When I go to work in the morning, my main goal is to make people happy. The fact that a happy, motivated person delivers better value is only an after thought. But the two do go hand in hand. Autonomy, Mastery and Purpose make the world a little bit better, employees a little bit happier and the products we produce a little bit more valuable.