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.
Let's be realistic. Nobody can invade the US. Two oceans, vast territory, sparse population make that impossible from the get go. Not to mention the fact that what, 1/3 of the US population is armed to the death dreaming of the day they could make use of their arsenals. The sheer amount of troops required to keep the land and population under control, and the logistics to feed them all rule out pretty much any Earthly military power.
Nuke? Missile strikes? Naval blockade? All plausible, if difficult.
But an actual boots on the ground invasion? Impossible.
US is investing into microchip industry so that they don't get invaded over the internet.
As to boots in the ground, you are just naive. The only thing that stops China or Russia from invading US is US military potential. The money that goes into military buys you peace.
No, i am not naïve, you just have no idea how militaries, amphibious assaults and logistics work. How many hundreds of thousands, or millions of soldiers are required to conquer the US? How do you supply them? For reference, the invasion of Sicily had 160 thousand, and had the advantage of being against an enemy with no will to fight and within less than a hundred kilometres from a friendly shore for supplies. And then you have a population, which again, is highly armed.
The US spent more than half of its existence with practically no armed forces. Yes, warfare has drastically changed and various amphibious assault and supply ships now exist, but there are still none in anything close to the quantity required to supply multiple hundreds of thousands of soldiers and their equipment across an ocean, and there's also a much heavier need for logistics.
The US can cut the entirety of its army and air force tomorrow and just keep the navy and marines, and it's still invincible from invasion and will remain so.
It's like the misconception that the US armed forces somehow have anything to do with freedom ("protecting"), of American citizens or otherwise. It's just stupid American propaganda that doesn't make sense if you think about it for a bit.
Security is what allows everything else to exist. You can't just say "Let's liquidate military and spend all that money on children". This would last only shortly until China or somebody else invades US.
Now, I am not saying to not pay for meals. Investing directly in children is probably one of the better ways to improve future outlook of a country.
I am just saying your logic is flawed and there is no easy way to compare the two.