What are the moral and legal consequences of "not thanking" government for not providing viable grants?
Academic publications are in general not the right place for politics. And especially not for personal vendettas. Doing the latter is deeply unprofessional (though I'd wager some great scientists did this as well).

However, government officials and institutions are public not private actors and as such are in democratic societies put to more scrutiny (in their official function) than private actors. Addressing StrongBad's concern of people starting to "not thank" your publisher,supervisor etc, this is definitely a difference I would see.

For contemporary major moral discussions - like "should we start a genocide or not" - I'd say the bigger moral question can trump the professionality aspect by far though.

Now that we covered the general and extreme cases, back to the dirty middle ground.
Criticizing a political official or institution who acts in a researchers opinion damaging to science (or to society by his stance to science) or who likes to claim supporting science while his acts paint a different picture, I'd consider a borderline case. 
It's a public body and it affects science, thus to some degree relevant for the audience and the author. Especially when there is no official body properly representing the scientific community in that country, such a statement may be a reasonable approach to inform the public about the opinion of the broader scientific community. But it comes off as petty easily if it's just general critic for a particular agenda that doesn't suit your own ideas or if it seems you are just angry because you in particular didn't get funding while others did. 

So legally, it's irrelevant in most countries, as long as you don't include libel or insult (depending on country). It is, in general, unprofessional, but sometimes the bigger issue at stake may still validate it morally.

It's basically your individual choice to break with the professionality in order to further your political agenda. It may hinder your scientific career and cost you reputation, while helping your agenda. However, if you're unlucky it may also have the opposite effect and along with your own reputation loss, cost your political movement reputation with conservative people/voters/observers. In the end, it is very context depending - who are you criticizing, for what reasons, who is your audience and how receptive may they be to your message. Same for your career. If your scientific peers agree with your opinion they may ignore your breach with professionality - but does that also hold for international colleagues who may have no idea what you are ranting about?