Here's the short story, from the Help system:
Many apps, including TextEdit, Pages, Numbers, and others, automatically save versions of documents as you work on them. At any time, you can browse through document versions and go back to an older version. You can also explicitly save a version.
A version is saved automatically every hour, or more frequently when you’re making many changes. A version is also saved when you open, save, duplicate, lock, rename, or revert a document.
There is also a KB Article on the Apple Support Site that goes into detail.