The theory of comparative advantage is an economic theory about the work gains from trade for individuals, firms, or nations that arise from differences in their factor endowments or technological progress. In an economic model, agents have a comparative advantage over others in producing a particular good if they can produce that good at a lower relative opportunity cost or autarky price, i.e. at a lower relative marginal cost prior to trade. One does not compare the monetary costs of production or even the resource costs (labor needed per unit of output) of production. Instead, one must compare the opportunity costs of producing goods across countries. The closely related law or principle of comparative advantage holds that under free trade, an agent will produce more of and consume less of a good for which they have a comparative advantage.
David Ricardo developed the classical theory of comparative advantage in 1817 to explain why countries engage in international trade even when one country's workers are more efficient at producing every single good than workers in other countries. He demonstrated that if two countries capable of producing two commodities engage in the free market, then each country will increase its overall consumption by exporting the good for which it has a comparative advantage while importing the other good, provided that there exist differences in labor productivity between both countries. Widely regarded as one of the most powerful yet counter-intuitive insights in economics, Ricardo's theory implies that comparative advantage rather than absolute advantage is responsible for much of international trade.
Adam Smith first alluded to the concept of absolute advantage as the basis for international trade in The Wealth of Nations: