The law of comparative advantage states that countries should specialize in producing and exporting goods and services in which they have the lowest opportunity cost, and import goods and services in which they have the highest opportunity cost. This allows countries to maximize their total output and consumption through international trade, even if they are less efficient at producing certain goods than other countries.