The LORD replied to Moses, "Whoever has sinned against me I will blot out of my book. Now go, lead the people to the place I spoke of, and my angel will go before you. However, when the time comes for me to punish, I will punish them for their sin."The holiness of God requires that sin be both punished and forgiven. At this point in history God provides the rules for which his people can know what is sin and provides a way to satisfy God's wrath through animal sacrifices and the tabernacle while still maintaining contact with his people (Exodus 20-31). Because God is Holy, he is just and justice requires punishment.
... And he passed in front of Moses, proclaiming, "The LORD, the LORD, the compassionate and gracious God, slow to anger, abounding in love and faithfulness, maintaining love to thousands, and forgiving wickedness, rebellion and sin. Yet he does not leave the guilty unpunished; he punishes the children and their children for the sin of the parents to the third and fourth generation."
Punishment and Forgiveness seem to be opposites in a way. Love is the only thing that can bring them together. John Piper has wonderfully summarized God’s eternal solution in this way: "The wisdom of God has devised a way for the love of God to satisfy the wrath of God without compromising the justice of God."