Your solar system should last well over 25 years.
The general rule of thumb in the solar industry is if your roof is 25-30 years old, you should look at replacing your roof prior to installing a system. At the very least, have it inspected beforehand.
If you put solar on a roof that needs to be replaced after a couple years, it's not a big deal. You'll just need to work with a roofer who is comfortable taking the panels off and then putting them back on. Most roofers are capable of this these days.
_12385522704667-png.png?width=940&height=788&name=Should%20I%20replace%20my%20roof%20before%20going%20solar_%20()_12385522704667-png.png)