This problem isn't limited to large companies. I'll go from the general/theoretical into the specific/actionable below.
On Motivation
(I apologize beforehand for a section full of potentially obvious statements. Please skip to the next section as soon as this bores.)
- People have different motivations. It's going to be well-nigh impossible to motivate a person who is primarily motivated by impact if the job/team/company is low-impact.
- It's not your job to motivate others. Yes, at some level, there are many things that you can do, as a software leader, to completely destroy everyone's motivation. But assuming you aren't doing that, people need to ultimately be responsible for themselves. Some people expect their boss/boyfriend/company/parents/team/wife to make their life interesting and fun. Others find the interest in almost everything they try. You want the latter sort of engineer.
- Understand some common modes of motivation, and learn some techniques that cater to each. Mastery. Sense of purpose. Challenge. Financial compensation. Public recognition. Skill-building. Fame. Opportunities to meet hot guys/girls. Intellectual stimulation. Physical pleasure / relief from pain. Reduction of risk. Comparative superiority. Sense of achievement.
What You Can Do
- Help each individual discover their motivation. Most people don't understand this about themselves, though many talk confidently as if they do. I've interviewed hundreds of software engineers; none have ever said they're primarily motivated by money or career advancement, though clearly some must be. Don't try to find a person's motivations by asking them directly -- only the rare introspective, non-self-deceiving, self-confident person can answer this accurately. Instead, listen carefully to what questions they ask. A person's interests are easily observed by listening to what they like talking about.
- Match people to roles that tend towards Pareto Optimal. Once you understand everyone's motivations, it's much easier to match your team's needs with what each person is motivated by.
- Hire with this balance in mind. If you have a team full of people that hate working on test automation, and yet that's your primary need, don't hire yet another person that hates test automation. This point is embarrassingly obvious when stated this way, yet I see engineering leaders do this all the time. "We should hire only super-senior rockstar distributed systems architects!" Good luck keeping a whole team of them motivated.
- Help people discover the interest and challenge in each role. Smart people are curious about the world, and tend to find the interest and challenge in almost everything they do. Most things are fascinating if you look deeply or broadly enough.
- Show the path to growth. Every job has distasteful elements. You make those more palatable by showing how the less attractive stuff builds towards something more interesting. Assuming you've done the groundwork to make sure that's the case.
- Have a strategy around dealing with the pain. One strategy is to just spread the pain evenly (much like on-call rotations at some companies). Another strategy is continual hazing of newcomers (e.g. residency in the medical profession). You could pay more to incentivize the least attractive roles (e.g. high wages in the garbage collection profession). You could outsource the painful stuff. You could hire people who actually love what some others might consider painful. You could intersperse periods of necessary pain with more enjoyable things (e.g. "bug bashes" in some companies, morale events, fun sprints adjacent to tough sprints, etc).
- Recognize achievement and sacrifice. Sometimes all it takes is to publicly recognize that you've asked someone to do something painful, and to thank them for their sacrifice. Remember that this praise and recognition is free to give - maximize that.
- Bias towards sustainable motivators. Pay increases are short-term motivators for people who otherwise have non-financial motives; it's rarely a sustainable way to keep many engineers long-term. If a person is motivated by a sense of mission and purpose, it's much better to make sure you're doing a good job explaining how that person's actions accrue to the team's mission.
I work incredibly hard to make sure I hire people and assign roles that map well to a person's core motivators. This, for instance, is why I never try to "sell" someone into a job. If you're great at selling people into roles, you're only asking for trouble down the line; there's a way in which you could become great at disappointing people long-term. Instead, I try to discern what motivates people, and match them into a role only if I believe there's a great fit.
That's all fairy-tale Pollyanna advice, though. You might instead find yourself in a terrible company with a horrible mission, surrounded by shifty or uninspiring coworkers, thrashed by a CEO chasing short-term earnings, up to your ears in engineering debt. In that case, you need to get out -- none of my above advice is truly applicable then.