It works out for many people if they plan but even then, many people do not know when they will move and the median time an American stays in any one home is 13 years that is an all time high that peaked at Covid. Of course it depends on the price of electricity as well. So pretty much in a low cost electric area many would never recover the cost.
Since I love electronics I would like to have a few panels on the roof as they could be positioned on the side of a HIP roof and barely seen but I would never see any return on them paying 10 Cents kWr 24/7 Then there is the messy part of putting holes in my roof.
If your younger and stay a long time, it might make your house look old as the panels deteriorate (hopefully a new roof at the same time as the panels) also keeping in mind, todays panels will look like relics in 20+ years as new technology makes them look like roof shingles. But the key here is, in low electric cost areas your home stands out like a sore thumb if you have solar on your roof. On our roof though, it would work as the south side is the side of the house on a hip roof.
2010 that number was 8 years median, 2015 11 years