Nobody has ever fought a war over the oxygen in the air because there's plenty of oxygen to go around. We fight over things that are scarce and valuable. Historically, most wars have been fought over land and people. If you win you get to force your subjects to collect raw materials from the land. Sometimes these raw materials are mineral resources. Historically, most slaves have been forced to cultivate food.
It's hard to comprehend how important food staples used to be. In Edo Japan, wealth was measured in koku (石). One koku is (in theory) enough rice to feed one man for one year. The amount of koku a daimyo controlled was basically how many people he owned because a region's food staple production determined its carrying capacity and the human population grew until it hit carrying capacity. In other words, we bred until we were on the edge of starving to death. Most wars have ultimately been fought over land because land determines food production and food production was a matter of life and death.
My grandfather, who grew up in Taiwan before the green revolution, was too poor to afford rice. He ate sweet potatoes instead.
The green revolution of the 1950s and the 1960s increased food production faster than our population growth. On the Chinese version of TikTok[1] there's a video of a guy eating a bowl of white rice with a spoonful of soy sauce. The comments are all of people feeling sorry for him. We have so much food these days that eating nothing but rice makes you surprisingly poor even by Chinese standards.
World War II ended in 1945—right before the green revolution. There has been no direct war between major world powers between then and now. I don't think this is a coincidence. Wars are usually about land and land is usually about food production and food production skyrocketed in the decades after World War II. (Birth control became widely adopted around the same time too.)
We still have small wars. We fight over oil and ideologies. But cars and capitalism aren't as important as food production. Fighting wars over food is stupid when food is cheap. Less fighting over food means less fighting overall. Countries being at peace with each other set the conditions for us to build more complex, interdependent trade networks. I think the idea that we're all human beings, regardless of our race, religion, sex and country of origin gained increasing power because cooperation is a winning strategy when there is enough to go around.
I predict that if per capita food production returns to the levels of 1914 1776[2] then so will humankind's ethics.
Republican Rome is the example I know best, and...it sorta fits?
Rome fought a lot of wars, and they were usually pretty extractive: sometimes total wars in which the entire losing side was killed or enslaved, other times wars of conquest in which the losing states were basically left intact but made to give tribute (usually money and/or soldiers for the legions). They definitely relied on captured foreigners to work their farms, especially in Sicily where it was hard to escape, and they got so rich from tribute that they eliminated most taxes on citizens in the 160s BC.
It's not clear that Rome was short of food and slaves when it started those wars, though. If anything, they sometimes had the opposite problem: around 50 BC so many farmers and farmers' sons were being recruited into the legions that Italian farmland wasn't being used well. I think the popular consensus is that a lot of warfare and especially enslavement was a principal-agent issue: Roman generals were required by custom to split any captured booty with their soldiers, but were allowed to keep all the profits from slave-trading for themselves. Enslaving a tribe of defeated Gauls was a great way to get rich, and you needed to be rich to advance in Roman politics.
To summarize, Roman warfare during the republic was definitely essential to Roman food security, but they got into a lot more wars than you'd predict from that factor alone.
Clear exceptions to the rule include the Social war (basically an Italian civil war), the third Punic war (eliminating the existential threat of Carthage), and some of Caesar's post-dictatorship adventures (civil war again).