I find mechanical options less interesting than roleplaying ones
As a result this answer isn't going to focus on how you can earn this kind of thing with rules, and more on how you can earn this kind of thing through your DM.
Essentially this boils down to telling your DM you have a cool idea, and asking them to help you achieve it. You can add your own input into the how if you like, or maybe just leave it to the DM and then when you see them offer that opportunity it is your cue to get your RP on and go for it.
As an example, one of my characters is just a memory rather than a real person, as such I agreed with my DM that the only way they can really die is if their patron forgets about them. This leads to interesting RP, a change of mindset when playing the character (death is now even less important than ever, so my wizard tank can be even more reckless), and given how easy resurrection magic is and how uncommon dying of old age is, the only mechanical benefit is not having to hand out money for diamonds (which is just DM intervention anyway).
Whenever you plan a character it is good practice to have an end goal in mind and discuss that with the DM, then you can both work on having the story achieve that, and the surprise is the how rather than the what. You can RP the character growth to get there and tell a great story.