The market IS very good at that, what it's not good at is handling externalities for citizens of a country that arise from taking the most efficient market path.