They design the ENGINE to do its job. Then they pick an oil that provides the best all-around combination of protection and efficiency. Sometimes they screw up the engine design (BMW, I'm looking at you...) and have to spec 60-weight oil to make engine bearings live, but its relatively rare. I think its an overstatement when people say "5w20 is all about fuel economy" when so many engines have been observed go 200,000 and more miles on it. But fuel economy certainly is a factor when the manufacturer comes up with a spec., but I think first and foremost they look at meeting a minimum level of engine protection. And dont forget sometimes thin is better: higher flow through timing chain sprayers and under-piston sprayers may be something that the manufacturer specifically WANTS for better protection, not just economy.
In the case of things like variable valve timing, older diesel HEUI systems, and cylinder deactivation that depend on the oil as a hydraulic fluid to actuate mechanical components, the timing of those actuations as measured by the engine controller may also depend on the fluid (oil) being in the right thickness regime. Granted, there's a lot of tolerance built into most of those systems, but there have been cases of people throwing Xw30 or Xw40 oil in their MDS/VCT Hemi because "5w20 is all about fuel economy and I don't care about that" and then getting error codes with one of the system's response time is outside the tolerance allowed by the controller. No *damage*, but an error code that goes away when thinner oil is put back in.