What is memory?

How does memory work?