If your roof is too old or worn down, it's best to replace it before installing solar panels. Some installers offer both services, which can bring down the cost by combining the projects.
If your roof is older, but not at the stage of replacement, you can still install the system. However, you'll likely end up paying for the labor to un-install and re-install the system when you do end up replacing the roof. This cost isn't typically welcome when you're already paying for a new roof.