Buy farmland -- and either develop it into a farm or lease it to farmers.
1) In a country with a strong rule of law.
2) In a country with a strong and growing middle class, where the poor are not fomenting rebellion.
3) In a country with a strongly diversified economy.
4) In a country with solid political stability.
5) In a country actively attracting foreign investment, evidenced by agricultural tax breaks and other incentives.
6) Buy land with a freehold title.
7) Buy land with multiple water sources (e.g., rain, river, underground aquafer, holding ponds, etc.).
8) Plant high-value exotics (e.g., mangos, limes, avocado, bananas, pineapple, passion fruit, gourmet coffee, cacao, etc.).
9) Do not compete against the big agricultural companies and their mass produced foods.
10) Have the land professionally managed by a multi-generational farming family with deep ties to the locality and, ideally (if your farm is large enough), with connections to the central government.
11) Serious on-the-ground due diligence is also absolutely critical.
I am likely leaving out a few factors. Even with all these precautions and tailwinds at your back, problems may still arise (e.g., COVID, labor issues, fire potential in the dry season, theft of fruit, a potential new pest or disease, etc.). You need to stack as many factors as possible in your favor, because farming is hard. But it is also extremely lucrative, if done right. Especially in an inflationary environment.