You are exactly right that staying healthy is a skill plus some luck...being/remaining healthy is a skill.. partially due to being lucky.. also, learned to a degree..
The skill part has to do with how and what you train and starting from what age. The luck has to do with what we come into this world with genetically, which we have no volition over (at least not yet).
If you have certain physical predispositions, you may be able to minimize their impact through training, but they are still there. And a predispostion to injury will have you injured more often even with good and timely training habits.