Over the past two years, the price of coffee has fallen more than 50%, proving me extraordinarily wrong when, in May 2011, I worried about soaring coffee costs. I wasn't alone, however. After the cost of coffee had more than doubled over the previous two years, Kraft Foods (NASDAQ:KRFT) and J.M. Smucker (NYSE:SJM) raised prices on their respective Maxwell House and Folgers brands, and Starbucks (NASDAQ:SBUX) raised prices on both its packaged coffees and some of its in-store beverages. Now, prices are basically where they started, putting coffee companies in an interesting position to either keep the price increases and boost profit margins, or start undercutting each other to take market share.

Just a little off the top
Kraft and J.M Smucker already fired the first shots in February, lowering prices on their coffees by about 6%, enough to be competitive without sacrificing all the benefit of lower costs. Starbucks is now  lowering prices on the bags of coffee it sells in grocery stores by $1 per bag, a 10% drop for its Starbucks brand coffee and a 13% drop for its Seattle's Best brand.

Interestingly, Starbucks' Via instant coffee, single-cup pods, and in-store beverages will not be affected by the drop. These are higher-margin items anyway, so leaving those prices as-is will do the most to protect gains from lower costs. Many people come to their nearby retail location to pick up a bag of coffee as well, so cheaper bags can act as loss leaders to get customers in the store, where they might stick around for a $4 latte.

Perhaps there is a third option
It may behoove Starbucks to lower prices on its K-Cups and Verismo pods, giving it an edge against Green Mountain Coffee Roasters (NASDAQ:GMCR). However, Green Mountain seems to be willing to give up its margin advantage willingly, by converting many of its blends to fair-trade beans. That will raise costs quite a bit, but the company has promised not to pass on those costs to customers. This move may help to win customer loyalty, however, allowing the company to make up on volume what it loses on margin.

Meanwhile, cafe competitor McDonald's (NYSE:MCD) is investing $6.5 million to help Guatemalan farmers produce more high-quality beans using sustainable methods. McDonald's U.K., New Zealand, and Australia already source all of their coffee from Rainforest Alliance Certified beans, and the Guatemalan investment should give the company access to even more supply for its other stores. That, in turn, may give investors a reason to smile.

On the other hand, while not all of Starbucks' coffee is fair trade, 90% of it is "ethically sourced," according to Coffee and Farmer Equity Practices, a set of standards Starbucks developed with Conservation International a decade ago. The company's goal is to reach 100% by 2015.

The Foolish bottom line
Coffee in the grocery stores should get a bit cheaper for now, which is a welcome change from the price increases of a couple of years ago. But rather than growing fat on increased margins or trying to undercut one another to take market share, some of the bigger coffee companies are using their profits to invest in more ethical and sustainable production methods. This strategy can go a long way to winning the hearts and wallets of customers and investors, but it's difficult to say which company benefits the most. Add these companies to My Watchlist to see how the trend develops.

Fool contributor Jacob Roche has no position in any stocks mentioned. The Motley Fool recommends Green Mountain Coffee Roasters, McDonald's, and Starbucks. The Motley Fool owns shares of McDonald's and Starbucks. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.