I think for almost all countries the taxes developers working for foreign companies pay outweight the higher costs of hiring some of them for building software for the government.
Let's say government hires 1% of the developers in the country, foreign companies pay them 3 times more and if not for outsourcing 50% of these people would have to emigrate.
If X is base salary ignoring outsourcing then the country would earn
0.5 * X * tax_rate - 0.01 * X without outsourcing and
3 * X * tax_rate - 0.01 * 3 * X with outsourcing
So the change is (3 - 0.5) * X * tax_rate - 0.01 * X * (3-1) =
2.5 * X * tax_rate - 0.02 * X = X * (2.5 * tax_rate - 0.02)
So in this simplistic example for the country to benefit from outsourcing it suffices that tax_rate > 0.008 which is pretty much always true.
Let's say government hires 10% of developers, nobody would migrate and the salary difference would be 500%. Even with such unrealistic assumptions the tax_rate would just need to be higher than 10% for the country to benefit from outsourcing.
tax_rate > (5-1) * 0.1 / (5-1) = 0.1
If you want to play with it it's:
tax_rate > ((salary_foreign - salary_domestic) * percent_hired_by_government) / (salary_foreign - (salary_domestic* forced_migration))