I read a lot of psychobabble and softball articles about the psychology of aging. It's all basically simple and the same:
Use it or lose it.
The idea is to stay active both by yourself in doing inspired activities and in contact with other people.
I can go back to Erik Erickson's archaic theory of eight stages of life from around 1971 which despite all its psychobabble, comes down to one thing:
You're either active doing something you feel has meaning and interacting socially and intimately with other people or you're alone in a room somewhere, not doing much of anything, feeling sorry for yourself.
One reason I don't like psychobabble is that they make everything a dramatic either-or situation. Most older people aren't intensely active or popular with a big group of people but they don't feel lonely and depressed either. They live adequate, comfortable lives day by day.
You don't need some great purpose in life or deep intimate relations with other people.