We model optimal contracts and the evolution of precedents by introducing imperfect enforcement into a standard incomplete contracts setup. We assume that biased trial courts can refuse to verify novel evidence but are bound to respect precedents, namely to verify evidence that other judges verified in past cases. Despite judicial biases, optimal contracts are innovative (contingent on both precedents and novel evidence). Noisy evidence and judicial biases, however, introduce enforcement risk and cause incentives to be low-powered. The use of innovative contracts is key. Their litigation refines the law and makes it more informative, so enforcement improves. As a result, parties can in turn write more complete contracts, which enable higher- powered incentives and improve welfare. This beneficial mechanism is hampered by judicial bias, which slows down legal evolution and causes enforcement risk to persist for a long time.