This is something I think about a lot. No matter how much time we spend on software design and doing things "right", in 5 years it's all going to get thrown out by someone who thinks the codebase needs "modernizing".
It's actually a bit reassuring to me. Things only having a 5 year lifespan means you shouldn't spend a lot of time worrying about them. Code is meant to be disposable, and the less we treat it so, the more we hold ourselves back.
If we treat software as permanent, we hold ourselves back from making risky changes that wreck it.
If we treat software as temporary, we hold ourselves back from worthwhile improvements that will have enduring value, especially if they are fairly difficult.
It's actually a bit reassuring to me. Things only having a 5 year lifespan means you shouldn't spend a lot of time worrying about them. Code is meant to be disposable, and the less we treat it so, the more we hold ourselves back.