GitHub had no reason to sell to Microsoft, they could have remained the bootstrapped company they started as, and rode the SaaS boom, since they were profitable on day 1. Seems a bit unfair to blame Microsoft though, because it was the founders who decided they wanted that sweet VC funding and Andreessen was happy to pay out.
Not sure if it mattered after that but they had that weird Tom Preston-Werner scandal that got him fired. Since he was the CTO, I kind of suspect that sent them on a collision course with needing to exit the VC round and Microsoft paid out.