The Lamb of God

Why was the lamb slain at the foundation of the world? So that light could become darkness, good could become evil, the sinless could become sin, and we could have sentient life with free will.