With care the 15-22 can last a long time, however it won't last forever.
On both the 15-22 and a traditional AR the barrel won't last forever. Both are replaceable, but the AR has the advantage of barrels being ubiquitous and easily replaced by owners without requiring a gunsmith. The barrel on the 15-22 can be replaced by an owner, but replacement barrels are no where near as common or as easy to get.
The bolt carrier group on an AR will eventually need replacing, as will the bolt on a 15-22. As with the barrel, the AR has the advantage of easy parts availability for the bolt and bolt carrier group.
I built my AR and can replace every part on it when those parts wear out. I can also replace the parts on a 15-22, but some parts are held close by Smith & Wesson. This just makes things tougher for the long term life of the 15-22.
I also have a few Remington shotguns. These guns will outlast my 15-22, but parts will still eventually wear out and need replacing. For the 870 parts are easily available and replacing them is about as easy as it gets. A better analogy might be my Glock pistols. The Glock pistols have a polymer frame somewhat analogous to the polymer upper and lower on the 15-22. In both cases the long term life of these components looks good, but in both cases when these wear out it will likely signal the end of the life of that specific gun. Replacing them will likely be more trouble and at greater cost than simply retiring the gun and getting something new.
Certainly with care the 15-22, 870, traditional AR Rifle, and Glock will last a very long time, but of these guns I have mentioned the 870 and the AR are the ones with the clear advantage due to parts availability and ease of replacement of those parts.
If you only shoot a couple hundred rounds a year then the gun should be able to be passed to your heirs. If you shoot several thousand rounds a year and do that for decades then your heirs will get a wall hanger.