Part of being a distribution monopoly is delivering power to everyone, not just places where it's profitable. People in rural areas are able to afford grid electricity because the disproportionate cost of delivering power to them is subsidized by people living in cities paying the same rates.
Rooftop solar being cheaper overall than a grid connection for some people isn't that surprising. There are lots of other costs and externalities associated with running a grid that don't need to be contemplated for off grid home solar.