Ricardo's mistake is not thinking about development; comparative advantage is optimal now, but a society that just makes coffee beans is going to lose in the end to the one that makes microchips because of the difference in how the economy and society develop over time.