Comparative advantage describes how trading parties will choose to produce more of a good that they have a comparative advantage of, and use that to trade for other goods that they don't have a comparative advantage in. Comparative advantage forms a foundation for international trade.
Comparative advantage is why there are call centers in India, manufacturing in China and highly specialized capital intensive labor in the US. It makes sense for China to do all manufacturing electronic goods and trade it to other countries that are specialized in producing other goods.
Conversely, an oil producing country will have a cheaper access to raw material for chemical products. They have a lower opportunity cost of producing more chemical products compared to countries that do not have access to cheap raw materials. This drives more chemical production in oil producing countries.
However, there are cases where countries, governments and business lobby together to protect niche interests. This can effectively keep foreign, cheaper goods out of the market to protect domestic businesses. However, in the long term, this might not good solution as neighbouring countries will be better off as they have to spend less to get the same goods.