The reason God tested Abraham was to show us what not to do.
Jesus answered him, "It is also written: 'Do not put the Lord
your God to the test.'"
It was a common belief at the time that the gods wanted child sacrifices,
by having their god intervene the story showed the Jews that their god didn't approve of this act and they weren't to follow that ritual.
God also sacrificed his son to show us what not to do.