The relevant economic concept is called "comparative advantage": https://en.wikipedia.org/wiki/Comparative_advantage.