Perhaps all of us, somehow, are seeking meaning. Many of us long for immortality. Leaving a legacy is one way for us to become immortalized. People create legacies in different ways. Some people need to build something physical, like a skyscraper or a cathedral, to leave their legacy.
Authors leave their books and articles.
Songwriters leave their lyrics. However, it is unnecessary to leave behind something concrete in order to leave a legacy. What gives our lives meaning, I believe, is how we touch the lives of others. Unless we choose to live in complete isolation, we all touch the lives of other people constantly. Often, we are completely unaware of the ways in which we touch or affect others.