MSFT doesn't have to hire just anybody. If they pay more than Google, etc, they'll draw people away from those companies. If they pay more than JP Morgan and Goldman, they'll draw people away from those companies. If they pay more than the law firms that significant numbers of CS people leave engineering for, they'll draw people away from those companies. If the whole industry raises salaries to compete, that will convince more people to go into engineering.
Here is MSFT's basic problem. The kind of people they want to hire often have better options. I left software engineering because I didn't like the constant layoff/hire cycle, the compressed salary scales at the top end, the need to get an MBA to go into management tracks, the lack of benefits, etc. In law I'm making more money even after student loans, and have far more headroom. I have an office with a door that closes and a secretary. I don't work exclusively with men. I work in a downtown high-rise, not some god-foresaken suburban office park. Based on my experience, I told my brother to stay out of STEM, and he took his physics degree to an investment bank. If some bright kid asked me to help him choose between CS and banking/consulting/law/medicine, I'd absolutely push him to the latter.
Tech companies need to get over their aversion to competing with each other for talent. They need to get over this "no poaching" "non compete" bullshit and stop trying to get the government to train their employees on the taxpayer dime. If they want to hire top-notch people away from other industries, they need to start paying competitive salaries and offering competitive benefits and amenities.