Theory of Comparative Advantage

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 modelagents 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.
In 1817, David Ricardo published what has since become known as the theory of comparative advantage in his book On the Principles of Political Economy and Taxation.

Ricardo's example
In a famous example, Ricardo considers a world economy consisting of two countries, Portugal and England, which produce two goods of identical quality. In Portugal, the a priori more efficient country, it is possible to produce wine and cloth with less labor than it would take to produce the same quantities in England. However, the relative costs of producing those two goods differ between the countries.
Hours of work necessary to produce one unit
Country
Cloth
Wine
England
100
120
Portugal
90
80

In this illustration, England could commit 100 hours of labor to produce one unit of cloth, or produce {\displaystyle {\frac {5}{6}}} units of wine. Meanwhile, in comparison, Portugal could commit 90 hours of labor to produce one unit of cloth, {\displaystyle {\frac {9}{8}}} or produce units of wine. So, Portugal possesses an absolute advantage in producing cloth due to fewer labor hours, and England has a comparative advantage due to lower opportunity cost.
In the absence of trade, England requires 220 hours of work to both produce and consume one unit each of cloth and wine while Portugal requires 170 hours of work to produce and consume the same quantities. England is more efficient at producing cloth than wine, and Portugal is more efficient at producing wine than cloth. So, if each country specializes in the good for which it has a comparative advantage, then the global production of both goods increases, for England can spend 220 labor hours to produce 2.2 units of cloth while Portugal can spend 170 hours to produce 2.125 units of wine.

Moreover, if both countries specialize in the above manner and England trades a unit of its cloth for {\displaystyle {\frac {5}{6}}} to {\displaystyle {\frac {9}{8}}} units of Portugal's wine, then both countries can consume at least a unit each of cloth and wine, with 0 to 0.2 units of cloth and 0 to 0.125 units of wine remaining in each respective country to be consumed or exported. Consequently, both England and Portugal can consume more wine and cloth under free trade than in autarky.