He died the death that we deserve for all the bad things we have done. He took our punishment so that we can be pure in God's eyes.