There are lots of clauses placed into contracts that are not legally binding under current law. Some of those clauses are put in because the parties drafting the contract aren't necessarily aware that they're not legal, and other clauses are there so that if the law is changed, the clause might be able to come into effect.
An example, in my state, a real estate lender cannot seek compensation from the mortgagee-seller if a short-sale does not bring as much revenue as the mortgagee owes. Despite this, most short-sale contracts state that the bank may go after the seller for the seven years that debts may be collected in. Other states do not have laws preventing this, so if the seller moves out-of-state the bank might try to enforce against them, or if the laws in the state change then the bank may attempt to enforce.
As for the nature of illegal conditions in a contract, that's why contracts usually have clauses in them that state that if any part of the contract is deemed unenforceable, the rest of the contract remains in-effect.