Note: This article is adapted from an answer I wrote to a question at another site.
"In this is love, not that we loved God, but that he loved us, and sent his Son to be the propitiation for our sins."-1 John 4:10 (NKJV)
Christ was sent to be, and was sacrificed as a propitiation for the sins of His people. A propitiation (also called atoning sacrifice) can be thought of as a vessel for sin to be laid upon in order for justice to be exacted upon it (instead of upon the guilty party). We see this type in the Old Testament quite often, where animals (who cannot commit sin) were sacrificed to atone for the sins of man. However, this was not a spiritually sufficient sacrifice, but served merely as a foreshadow of what God Himself would do. Carrying out the sacrifice was how righteous men displayed their trust in God that He would provide that sacrifice for them.
God cannot allow sin to go unpunished, as that would be a lapse in His justice, making Him unjust. Because God is just, and cannot do things that are against His nature, His justice must be fulfilled, so the punishment for sin must be carried out.
"For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord."-Romans 6:23 (NKJV)
The word "death" here means "infinite spiritual separation from God", and this therefore means that a finite being receiving that punishment must receive it eternally (for an infinite amount of time). However, an infinite being (eg., God the Son) is capable of fulfilling that punishment for a non-infinite amount of time. This is what occurs on the cross when Christ exclaims "Why have you forsaken me?" At that very moment, the perfect communion that the Son had had with the Father for all eternity past was ruptured infinitely. The resurrection shows that this communion had been restored, the sacrifice accepted, and forgiveness for sin achieved and granted for all who believe and trust in that finished work alone.
"And you know that he was manifested to take away our sins; and in him is no sin."-1 John 3:5 (NKJV)
So, though Christ carried the sin of His people, He Himself was not guilty of sin, He was a spotless lamb, without blemish (ie., sin). So there was no sin that He needed to be forgiven for. If He had sinned, He wouldn't be God, and wouldn't be infinite, and could not have served as a perfect, infinite atonement for the sins of His people.