It is important to remember that evidence pertains to both criminal and civil cases. The preservation of evidence in either arena will differ, however, the term "chain of custody" almost always pertains to criminal cases.
In the criminal context, law enforcement (including police officers, prosecutors, forensic evaluators, etc.) must collect, preserve, and document each piece of evidence. Collection and preservation is the process by which evidence is obtained and stored in such a way so as to preserve its integrity (keeping it as pure and unchanged as possible). Documentation describes the evidence itself, as well as who, where, and how it was obtained. This begins the chain of custody.
The purpose of chain of custody is to account for where evidence goes at the time it is collected and thereafter. Think about it. Once evidence is collected it is inspected and analyzed. Generally speaking, every time someone has an interaction with a piece of evidence, it should be documented as above, thereby continuing the chain of custody. Chain of custody ordinarily ends once a trial is complete, and the original evidence is preserved for a set amount of time before it is destroyed.
If there is a break in the chain of custody, and evidence cannot be accounted for at any given time, then a defense attorney (or the defendent) will usually object to the evidence, and it could be thrown out.