There was no 'sudden change of heart'.
God works through what is called dispensations -- periods of time where man is expected to live under specific guidelines, or face judgement.
In the example you gave, you have to understand what has transpired.
The Jews have just been liberated from Egyptian oppression, and they are in the wilderness.
God is about to institute the dispensation of LAW, and here is what transpires, just before God gives it:
Exodus 19:1 In the third month, when the children of Israel were gone forth out of the land of Egypt, the same day came they into the wilderness of Sinai.
2 For they were departed from Rephidim, and were come to the desert of Sinai, and had pitched in the wilderness; and there Israel camped before the mount.
3 And Moses went up unto God, and the LORD called unto him out of the mountain, saying, Thus shalt thou say to the house of Jacob, and tell the children of Israel;
4 Ye have seen what I did unto the Egyptians, and how I bare you on eagles' wings, and brought you unto myself.
5 Now therefore, if ye will obey my voice indeed, and keep my covenant, then ye shall be a peculiar treasure unto me above all people: for all the earth is mine:
6 And ye shall be unto me a kingdom of priests, and an holy nation. These are the words which thou shalt speak unto the children of Israel.
7 And Moses came and called for the elders of the people, and laid before their faces all these words which the LORD commanded him.
Notice how the people responded:
Exodus 19:8a And all the people answered together, and said, All that the LORD hath spoken we will do.
According to C. I. Scofield, that is one of the biggest mistakes they ever made. They should never have said that. Instead, they should have humbled themselves and told God that they are sinners and can't begin to measure up to His standards.
Nevertheless, they said what they said, and at that point, God takes on a new facet, and death takes on a new meaning.
There are three -- (and I hope I'm not wasting my time here) -- but there are three types of judgmental action:
- justice = getting what we deserve
- mercy = not getting what we deserve
- grace = getting what we don't deserve
It is at this point that God institutes justice -- an eye for an eye & a tooth for a tooth.
The Jews lived under the dispensation of LAW up until Jesus Christ died on the Cross and the veil in the Temple was rent in twain from -- get this -- the top down.
At this point, the dispensation of LAW ended and the new dispensation of GRACE started, and we went from an eye for an eye to forgiving one another seventy times seven.