It is determined by three distinct, unwritten principles, none of which are directly related to resources, such as oil. Unlike Japan in World War II, or the Iraq invasion of Kuwait, the United States has never gone to war over oil. If you have oil and refuse to sell to the US, you are entirely safe from the US. Even if you preach hate against the USA, we simply won't go to war against you.
So, why exactly do we go to war? We only go to war if all three of these conditions are met:
- We think the target country is imperialistic. If they talk about conquering other countries, particularly US allies, they failed this test. Or, if they give the impression that they are in fact literally insane - and therefore can't assure the US that they are not imperialistic (Gaddafi). We learned this lesson from World War II Japan and Germany. We won't forget it for the foreseeable future.
- They are not willing to work with the US. Pakistan is the perfect counter-example of this. They are imperialistic (ask India) but consistently agree to work with the US - despite the rather crazy stuff they do and say. The US could have gone to war over Pakistan hiding Osama Bin Laden. We invaded Afghanistan over pretty much that same issue. But Pakistan said enough of the right things to avoid this. This was not an accident, Pakistan worked very hard to avoid a US invasion. We learned this lesson from Vietnam. We lost that war and nothing bad happened. Why? Because despite their communist imperialistic shouting, they were pretty reasonable.
- The country has to be powerful enough to be scary. Note attempting to buy or build nuclear weapons is just one of several ways to make yourself scary. We don't care about Sudan, etc. because even if they conquer a nearby country, we can still easily crush them without significant casualties on our part. It's just not worth it for a country that poor and weak. But we pay a lot more attention to Iran, Pakistan, North Korea, etc.
If you don't like the United States, you could say the US doesn't like "uppity countries". If you do like the US, then you can say the US "wields it's power responsibly". The point is, it's not about oil, it's not about genocide, it's about unrestrained imperialism.
In any case, you don't need to worry about us invading your country or even starting a revolution in it for oil or other resources. We learned our lesson about that about 60 years ago (1953 Iran debacle ).
No country is perfect. The USA is so powerful in large part because we learn from our past mistakes. We fix our problems, as opposed to relive them. When it comes to military might, the US has learned from painful experience, to invade only when it is like the Nazi Germany, not like Communist Vietnam.