It's about both cost and risk analysis. If you've got a lot of infrastructure, then you've probably already got a team of decent admins. Adding another server has a very small marginal cost. If you haven't, then the cost is basically the cost of hiring a sysadmin. Even the cheapest full-time sysadmin costs a lot more than you can easily spend with GitHub. Alternatively, you get one of your devs to run it. Now you have a service that is only understood well by one person, where installing security updates (let alone testing them first) is nowhere near that top priority in that person's professional life, and where at even one hour a week spent on sysadmin tasks you're still spending a lot more than an equivalent service from GitHub would cost.
In both of the latter cases, the competition for GitHub isn't a competent and motivated in-house team. It is almost certainly better to run your own infrastructure well, but the competition for GitHub is running your own infrastructure badly and they're a very attractive proposition in that comparison.
Outsourcing things that are not your core competency is not intrinsically bad, the problem is when people outsource things that are their core competency (e.g. software companies deciding to outsource all of the development - it's not a huge step from there to the people working for the outsourcing company to decide to also handle outsourcing management and start up a competitor, with all of the expertise that should be yours), or outsourcing without doing a proper cost-benefit analysis (other than 'oh, look, it's cheaper this quarter!').
If you think outsourcing storage of documents is bad remember that, legal companies, hospitals and so on have been doing this for decades without issues - storing large quantities of paper / microfiche is not their core competency and there are companies that can, due to economies of scale, do it much cheaper. Oh, and if that still scares you, remember that most companies outsource storing all of their money as well...
no windmills glued on the plane please
What do you think those big things under the wings are? When the throttle is at idle, they're being pushed around by the airflow from forward momentum.
SCCS, the source motel! Programs check in and never check out! -- Ken Thompson