It's a big question and not one I claim to have solved, but since you ask I'll go through things I think about :) I'll say up front it's a huge, ongoing challenge that I keep trying to improve on.
But to get to the question...
One thing to get out of the way: get money off the motivation table. It almost never works as a positive, but it can easily be a negative. Pay people well enough that they don't need to worry about it.
After that you have a few things to consider:
Are people doing interesting work? Everyone has to do their share of the daily grind, but do you have anyone on your teams who's doing nothing but the grind; or nothing but woolly R&D that never ships? Both are demotivating.
Are people doing a fair workload? Pretty simple. Make sure everyone's working to a comfortable, sustainable maximum. I find smart people are happy when they're doing what they do and doing it really well.
Do people have real input into how things are done? Hiring smart people then ignoring them is disastrous. Giving them room to move can be amazing.
How do people produce their best work? What are you doing to ensure they are in that mode as much as possible? Are they self-aware about getting themselves in their zone?
What frustrations do they have and how can you reduce those frustrations? Some things you can fix. Some things you need to escalate. Some things you coach on how to deal with it themselves.
Is the work and environment compatible with their personal values? It can be really simple, like making sure a family-motivated person can leave on time to get home to their kids.
What are peoples long term goals? Are you helping them get there? Have a specific learning plan, and give people opportunities to learn the way that works best for them.
A lot of this relies on having a weekly 1:1 meeting. I have one scheduled every week with every staff member; and I avoid rescheduling them if at all possible. I have a rolling set of topics including "what haven't we talked about that we should?" (a question a previous boss once asked me and I shamelessly stole :)).
Worth saying that you can do all this and other factors can still completely demotivate people. We don't control the world. Maybe one last thought is - if someone seems off their game, if something doesn't feel right, ask them what's going on. You can't help anything if you don't notice or care enough to ask.