the market does work for goods whose demand is inelastic

at the cme wheat costs 8.38 dollars per bushel, 31¢ per kg, and 1 kg of wheat is roughly two person-days' worth of food, 57 dollars per person-year

(of course an actual diet needs to be more varied and therefore slightly more expensive, but even just cooked wheat will extend your survival time under famine conditions by quite a lot)

let's start by dividing the cases to consider into ① cases where people have substantially more than 57 dollars per year to spend on food, whether in the form of production, money savings, foreign aid, or salable goods, and ② cases where they don't

we can subdivide case ① into case ①ⓐ where there are price controls, so that people who sell wheat at substantially higher prices than, say, 50¢ per kg, are subject to criminal prosecution, and case ①ⓑ where they are not

in case ①ⓑ you do not have a famine, and people do not starve, because even if delivering the food is very difficult and dangerous (①ⓑⅰ), due to pirates and collapsing currencies and whatnot, it will be profitable (for somebody anyway); maybe you'll have one merchant selling wheat at 2 dollars per kilogram and making an outsized profit, while another made worse choices and would need 3 dollars per kilogram and therefore has to take a loss from competing with the first merchant. and if it is not difficult and dangerous (case ①ⓑⅱ) then someone will sell wheat at 60¢ a kilogram in the supermarkets and there will be no outsized profits but still nobody will starve

in case ①ⓐ you might get lucky, maybe getting wheat into the country and distributed will not be difficult and dangerous (①ⓑⅱ), and so there's no shortages even though there are price controls. but if shipping costs go up, or bandits steal half the wheat in transit, or supermarkets can't open because of rioting, (①ⓑⅰ) selling wheat will be unprofitable at the legal price, and so merchants will do it as little as possible, and people will starve due to lack of not only affordable food but any food. wheat will rot in silos or be fed to livestock in order to avoid prosecution

in case ②, where people have less than 100 dollars per year and so can't afford to pay for the food they need to stay alive through voluntary exchange, their only hope for survival is to seize it by force, price controls or no price controls. this is a frequent occurrence throughout human history, and of course there's a whole continuum from a hypothetical state of perfect liberty, through transparent flat tax rates, through mafia protection rackets, all the way to raiding bands of thuggees and the holodomor.

systems that are closer to the totalitarian end of this spectrum tend to have frequent famines because, again, people starve due to lack of not only affordable food but any food at all; the holodomor is one example, but other examples are the irish potato famine, the ethiopian famine caused by the derg, the frequent famines in india under the british raj, and the greatest famine in human history, the great leap forward

because the cold-blooded-greed-powered market is, generally speaking, how people get fed in the first place, if you want to reduce the number of people who starve, you will let it function

i mean, unless you have a better replacement for the cold-blooded market, already debugged and working, but the track record of the proposed alternatives so far includes many of the worst atrocities in human history