Microsoft doesn't give out any software totally free, they always restrict your freedom somehow. The license always restricts you from redistributing it in some way or doesn't allow you acces to the source code.
I think what you mean is they're giving away some of their software free of charge, but there's still a catch, like not for commercial use.
The reason why they do it, is because it makes their software more populate, it's a loss leader. If they give some of their software away free of charge to students, it means that when they grow up and get jobs in industry they're more likely to buy it.