The Cost and Benefit of Horizontal Gene Transfer