But the government would be compensated for default by charging the insurance premium, so no, it wouldn't cost it anything. If the default rate was higher than expected, or if everyone defaulted, then yes, but in those cases goverment usually has to step in anyway as we've seen in the financial crisis. Besides, the insurance could only be available for very safe investments anyway, like short term money markets.