Becoming immortal and vying for legacy by rubbing your agenda on others may not be a recommended way of living ones life because it could compel a person to drive an ideology that may not work of others.
One can become immortal by leading a meaningful life that creates something that exists only because you are here. You did something that only you could do and that positively impacts others . Meaning your unique thinking and intention solves some problem in the world. Your work is not only making you better but also is making others better. It is like you becoming wealthy is making others also wealthier. Your work and service is your contribution to this world which could be consumed by others. Another way to of leaving a legacy is by having kids and parent them properly.
*Do read the Disclaimer