The sun is free, but not all plans will grow everywhere. In many cases, there just isn't enough sun, or the climate is wrong. The economics of growing, say, pineapples in England don't work out, in part because it's so expensive to grow them there (if that's even possible in a highly climate-controlled room), but also because transportation costs are so low.
It is possible to grow them in English greenhouses: wealthy Britons with skilled gardeners had them in the 18th and 19th century, and the growing middle class often rented pineapples to display at fancy dinners. As you said, cheap transportation is what ended UK domestic pineapple production.