A sandbox is software that allows you to run an application so that any changes it makes to your system are contained in a safe environment; this is discarded when the application and sandbox are closed.
Normally, when you run a program like your browser, it makes changes to your system: registry settings, internet caches, browsing history, and the like are all written to disk. On top of that, downloads of things (like potentially unwanted malware) also arrive via the browser and install themselves onto your hard disk. The next time you run the browser – or the next time that you even just boot your system – that spyware is still there, doing its spyware thing.
When you run software in a sandbox, all of those changes still appear to happen, but they’re never actually permanently placed on disk. When you exit the browser and its containing sandbox, all of those changes disappear. History, cache, settings … and spyware.