The problem with most places is that distribution is a natural monopoly: you don't want two or more lets of wires running to every house, so distribution monopolies are a natural consequence.
Production, however, is different; there's much more competition, which means that competitive pressure drives prices down.
Over time, distribution monopolies and other parties get more and more intertwined as they capture each other. The state uses distributors to levy taxes, unions parasitise the distributors and seek rents from their customers, companies capture regulators who set their prices, and that's why distribution is costly.
The beauty of rooftop solar is that you can completely disconnect yourself from the grid and thus the politics that drives prices up. It is true that giant solar farms in the desert and grid-scale batteries are more efficient, but they're captured and don't act in the customer's best interest.
In a world where distribution monopolies don't charge more than cost, where distributors are not agents of the state, rooftop solar would be more expensive than grid solar, but that's not the world we live in.