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.