To have a legacy, you need to have done something that is worth remembering. History is not fickle, the good and the great are as notable as the bad and the wicked.
Some will live in a collective consciousness. Names like Julius Caesar, Napoleon, or Einstein. Known by many, but perhaps by some without having a clue why. Yet what makes these figures more famous than other less well-known, yet arguably more important, people. What about Augustus, Qin Shi Huang or Brahe? (I am speaking mainly from an anglo centric point of view here, I know the Chinese or Danish may see things differently).
The ancient Egyptians used to destroy the cartouches of pharaohs they wanted to strike from history, yet we still know of Hatshepsut. For some cultures being forgotten was like a second form of death, as if some way your spirit would cease to exist if your legacy was erased. Maybe this is a consideration, how long do you want to be remembered for?
Once you are forgotten you have no legacy
We have lost the names of countless millions to the ages. The sailors on the Greek triremes, the wives of crusader knights, the faceless victims of colonialism. Those who live on only in records, disembodied names who only exist when somebody observes them. Heisenberg humans.
Most of us will be lucky to be remembered for anymore than a few generations, first as parents then as grandparents. Yet as your grandchildren pass who will be there who can remember your face, the way you smile or how they used to play football with you in the park? There are 7 billion people who will need to be forgotten in a hundred years.
Yet many if us are building our own legacy. More of us than ever are producing information about ourselves and the world. We are living in a legacy gold rush, furled by Facebook, twitter and blogs. Sites like YouTube and Wikipedia have given my generation a way to push their existence to millions, should the technology exist in a century there may be someone who stumbles upon an article or video you gave produced.
Myself? I am not going to be remembered as a great writer, scientist or leader and I do not wish to be known for my infamy.
All I ask for is to be remembered, at least for a little while.