If the software is to be used tactically or strategically or is core to your business, then having programmers who also understand the business can be key. They also need to understand the support and life cycle and what will cost your company to support the systems after release.
I don't think that cost is generally a real factor. If someone claims it is, they're ignorant or lying. If you outsource, you're paying someone else's profit margin on top of their costs. Any savings due to geographic labor market differentials is usually quickly made up in increased cost of communication and education, and the rate differentials are not as large as they used to be, since the developing world is called that for a reason.
There are lots of kinds of software out there. In many cases, you can outsource something and be fine. The problem is that that decision needs to be taken on a per case basis, and you cannot solve it in a one-size fits all situation.
I'm sure there are a million things to look for in the decision-making process.
There would be cases where development of a well-specified yet core piece of software might easily be outsourced to a company who specialized in that kind of work - for instance a system-level thing like a device driver or web server might still be outsourced by a company who made an appliance and wanted to specialize on the user experience more than the building blocks.
On the other hand, if you're going to be driving that web server in special ways and even though you have it well-specified, you are going to have this component tightly tied to major multi-phase development initiatives, you probably aren't going to want to outsource that.