A contract is a written document between two or more parties. They are typically NOT legally binding. In a D/s relationship contracts are used to outline the specifics of the relationship. Not every relationship uses a contract. If a contract is desired, the people need to sit down together and discuss and agree to every section.
Contracts are a form of negotiation that can help a relationships that might need a better form of organization and perhaps to try out something different. I recommend the contract be reviewed every so often so that it is still effective and working well for both partners.
Here's what wikipedia has to say about D/s contacts:
In BDSM, a contract is an agreement, usually written, between the dominant and submissive in a 24/7 or Total Power Exchange (TPE) relationship. It is the formal act of consent to the power exchange.
Some are very formal and will detail exactly what is expected and can run for multiple pages. Others are as brief as a single paragraph. Either way, one is derived by negotiation on the part of both parties. BDSM couples consider the contract to hold equal moral authority to a marriage commitment. As such, constructing a proper contract is very much like writing a pre-nuptial agreement.
My favorite resource for contracts: