You're getting at the concept of "Value of Statistical Life", or VSL. Back at the beginning of the Pandemic, there was an NPR podcast discussing the topic, which is how I first learned of it. It's interesting stuff.
Policymakers need some mechanism to determine the value of life, and how much they should be willing to spend to save one (or many). How much should the government be willing to spend (taxpayer money) to save one life? Economists try to estimate this quantity by figuring out how much compensation people demand as payment for accepting risky jobs. The current consensus seems to be between $4 and $10 million.
Back in 2002, the EPA tried to use a VSL that varied by age - there was a significant political backlash. There's a logical way to approach the question, which I think is what you are getting at. Fewer years remaining means you would be expected to contribute less to society, so your life is worth less. But, there is also an emotional element, e.g. "My spouse's life is not worth less than your child's life!"
But, there are lots of historical examples of some lives being valued more than others. Particularly people making brave/fateful decisions to save the lives of their children at the sacrifice of their own.
It also depends on what society values. Wisdom is valuable, but so is being able to work in a farm field, or program in Python. And, who has power? Older people usually have more power than younger people, so there is probably a selfish aspect in policy decisions - most people making policy are older.
Here's some more reading if you're interested: