In historical terms, a legacy is something that is handed down from one period of time to another period of time. A historical legacy can be counted in later times as a good thing or a bad thing. For example, the invention of the wheel (for carts, as a potters wheel, as a grinding wheel to help turn grain into flour, and as an early water wheel) in Mesopotamia can be seen as something good. The development of slavery is a bad legacy.
Sometimes countries or civilizations can leave a legacy. Buddha and Confucius left moral legacies. More than 2000 years ago the Greek Mathematician, Euclid of Alexandria, collected and wrote down ideas about geometry and measurement in a text called Elements. Students still use these ideas when they learn about mathematics. In Athens, people voted on what the city would do. Their early form of democracy is a cultural legacy.
Some families pass objects and ideas down from generation to generation. These heirlooms and ideas can also be called legacies. It may have to do with a person or many people. Individuals can leave a historical legacy.
Legacies are, more or less, what we remember about a person or a country. What an individual or a country does today might, in the future, be regarded as being important enough to be thought of as a legacy from the 21st Century.
Legacy is a similar concept as inheritance and heritage. It is something we inherit from our parents and pass to our children. Usually heritage refers to material and economical inheritance, while legacy refers to immaterial and cultural inheritance.