But that energy comes most probably from fossil fuels. If we can be more efficient in the delivery of this energy, we can improve what is called the aggregate efficiency.
We can deliver from sources close to us, demanding a bit more energy to deliver 1 ton of potatoes but being able to source this energy from renewable sources. We can do that because the delivery is shorter and closer to us. No need to ship freight or carry the potatoes in a truck for 1500km.
Cheaper fuel also means cheaper prices.
Another way to beat the energy aggregate cost would be that if the produce is micro farmed, either by yourself or by a local entity, is that you can use less fertilizer as the soil is not run to exhaustion. Less weedkiller as you can pluck the weeds yourself. Being in a controlled environment also means less plagues, or if a crop plague comes, less pesticide used. Fertilizers, pesticides, weed killers... All that comes from fossil fuels.
Totally, but all of that also allows us not to have 30-50% of the population working in farming. If you have enough money and enough time, you can absolutely live with a smaller foot print by producing your own food, but it's not something that scales well. And I'd argue that you probably have skills that would serve humanity better if you applied them to larger problems than plucking weeds, that is: you could have a much larger impact on saving humanity/the planet/the universe/your soul by not producing the food yourself and spending the time you save on other things.
Its a lot of fun to get things working, and then when you do: the plants do all the work.
No, doing it the first few times on a balcony - this won't be efficient. But, going through a few seasons and tweaking your plant code a couple iterations, maybe refactoring (the soil) a couple times: this will get you a long way towards highly productive gardening.
Start with a good compost, get your seeds started earlier in the season than you might think (window seedboxes), get things in the soil, pay attention to the plants, use your local resources, and most of all .. love what you do. All gardening can be rewarding.
Even if its not efficient at first. The more you do it, however, the better things get. Also: make that compost awesome.