Before Cydia 1.1, Cydia included a "Make my life easier" option that, if opted into, would automatically save all available SHSH blobs for your device. As of Cydia 1.1, Cydia assumes your life should be made easier, and it saves any available SHSH blobs for your device automatically every time you open Cydia.
Usage on iOS 4.x
To use this process, Cydia's servers must already have saved SHSH blobs on file for your device for the iOS version you want to restore to.
To use the Cydia server to restore to a firmware no longer being signed by Apple (e.g. 4.0.1), add the following line to /etc/hosts (Mac OS X/Linux) or C:\Windows\System32\drivers\etc\hosts (Windows XP+):
Note: On Windows, make sure you open hosts as Administrator.
Then go along with the restore process. If the restore fails after "Verifying iPhone restore with Apple" with iTunes error 3194 or something similar, you have not set it up correctly or saurik's server doesn't have your SHSH for that version.
How it works
It uses the hosts file to redirect the Apple firmware server to saurik's. His server has a ECID SHSH database, just like Apple's. When an older firmware request is sent to Apple, it will deny the SHSH request and error out. When it's requested at saurik's, if you've saved it, it finds the SHSH and continues with the restore.
iOS 5 update
This simple replay process no longer works to restore to iOS 5.x. Instead, you have to download your SHSH blobs to your computer, stitch your SHSH blobs into custom firmware, and use that to restore. See the JailbreakQA guide to restoring to iOS 5.x using SHSH blobs.