Being healthy, good social connections, meaningful activities, exercise, family you can depend on, etc. I wonder if the optimism is just a confounding factor, or rather just the middle man we can measure. Seems like having a good life would make one more optimistic about their prospects.
X is a rich family. Hard to be an optimistic person if you struggle to afford to live.