Consider one of the goats on the Day of Atonement (Yom ha-Kippurim).
In Lev. 16:21-22, it is written,
21 And Aharon shall lay both his hands upon the head of the live goat and confess over it all the iniquities of the children of Israel, and all their transgressions in all their sins, putting them upon the head of the goat, and he shall send it away by the hand of a fit man into the wilderness, 22 and the goat shall bear upon it all their iniquities to a land cut-off, and he shall let the goat go in the wilderness.
Here we see that a goat, who otherwise "knew no sin," had "all the iniquities of the children of Israel" imputed to it, and the life of the goat was a substitution for the life of the people of Israel. Likewise, our sins were imputed to Christ, just as his righteousness is imputed to those of us who are "in Christ."