A country that can't defend itself will be pray to everybody else and will not be able to do anything about environment or education.
You can bitch and moan all you want. Go visit Ukraine and see what happens when you live in a country that can't defend itself. Everything else is being put to side. Do you think they are discussing how much they should be spending to help with the effort to control global warming?
The simple fact is that having US reliant on chips supplied by a hostile power will eventually be US downfall.
But the invasion of Ukraine most likely has a lot to do with Russia gaining control over the supply of fossil fuels to Europe and the world. So even at a very high level, the things you say are far from cut and dried. Had Europe moved more resolutely towards energy independence then things might have been different.
Military security is only one kind of security. Military spending is only one way to create security. Most of the wars of the last 100 years have been about energy. And I suspect that most militaries exist primarily to perpetuate themselves.