Supply and demand controls prices. However, just a little surplus drives prices way down and a slight shortage drives prices way up. It is a far more delicate balance than you might think.
You are seeing it now with eggs. You saw it with gasoline, both ways. When Covid lowered the demand for fuel, prices dropped a lot. When Biden's mandates tightened supplies, just as the economy was coming out of Covid, prices skyrocketed.
A few years ago, new home construction outpaced demand and housing values dropped. With the current labor shortage, supply chain issues, there is a housing shortage in many areas, driving up home values.
The government gets a lot of flack for meddling in from crops, but generally it keeps food affordable.
These highs and lows are so important, most large consumers engage in forward contracting. The oil refineries buy futures contracts far in advance of their needs. Many farmers store their crops and buy futures contracts. That insures them a price above the cost of production, at the risk of missing out on a rise in prices. The huge dairies, "egg factories" and butcher hog producers, depend on futures contracts for feed, to avoid the ups and downs of the market. Everyone is covering their risks as best they can.
Long ago, slaughter facilities bought cattle and hogs at auction. A true supply and demand system. Now, they go to the feedlots and lay out how many they need, when they want them and how much they will pay. The feed lot signs a contract and has to control their costs to earn a profit. The feedlot cannot withstand the peaks and valleys of feeder calves at auction. So, they contract directly with the feeder calf guys. The guy running cow/calf operations must fall into line, too. So, the farmers trade the boom/bust price roller coaster for a smaller, but steady, profit. But once these contracts are set, these producers are not interested in auctions or individual on farm sales. A pig farmer cannot sell 10 feeder pigs to 10 different people, if he has a contract for his expected production 6 months into the future. Penalties for failure to fulfill your contract are often harsh.
Many of these futures contracts are published and investors often buy and sell contracts, hoping to buy low and sell high. If it looks like there will ba a shortage, investors will but contracts, planning to sell after the day price goes up. But investors that hold these contracts, increase the demand for the businesses that use the products held under contract. They are forced to pay more because of shrinking supply. The investor sells the contract at a profit, but never actually touched the commodity. If something happens that reduces demand or increases supply, even if just a little bit, investors lose out.
Perhaps, anyone wishing to watch the problems facing the egg producers, avian influenza, increased feed costs, increased transportation costs, increased labor costs, would have, 6 months ago, bought a few million eggs on contract for this date. Whoever sold that contract would be in a jam right now with reduced supply and no where to turn to buy eggs to fulfill the contract.