What you're describing sounds like epigenetics. Good environment and nutrition can turn on or turn off ceratin genes. These changes can then be inherited by the offspring, but the changes can also be reversed over time.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4517414/