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 a positive thing or a negative thing. For example, the invention of the wheel (for carts, as a pottery wheel, as a grinding wheel to help turn grain into flour, and as an early water wheel) in Mesopotamia can be seen as something positive. The development of slavery is a negative legacy.
Sometimes countries or civilizations can leave a legacy. In Athens, in Ancient Greece, people voted on their leaders. They created an early form of democracy. Greece, and later, Ancient Rome voted for their leaders for many generations.
Some families pass objects and ideas down from generation to generation. These objects and ideas can also be called legacies. It may have to do with a person or many people. Individuals can leave a historical legacy. 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.
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.