Cancer probably isn't as random as at seems, some types are known to have an inherited risk, others have been linked to environmental factors. As far as I can see there are many equally nasty things to fall prey to. I have often wondered if it's worth spoiling the best years of your life to try to extend what maybe the worst.
Doing all the right things when you are young lots of exercise etc ... Everyone I know who did a lot of sport, running etc when young from late middle age have suffered severe pain and nearly all have required at least one joint replaced by the age of 65 . Three have had cancer, and one has heart disease.
I walked a lot and been overweight most of my life and have similar issues some which were work related. So those lifestyle choices may protect some but not others.
However those in my circle who have the most significant health problems have one thing in common. Social isolation either because they made the mistake of retiring away from family and friends, then losing the partner they moved with, outliving their loved ones, or just not being able to make new friends because of shyness, trust issues, mental health problems. (Or just being cranky difficult barstwards)
So I would agree moderation, exercise if you can find something you en joy, regular connection with nature, and treasure friendships, and make new ones. You may not avoid disease or injury but you will cope better and have a better life whatever happens.