God, as our Creator, has the right to our full allegiance, nothing must come between us and him, nothing must be more important in our lives than him.
Sometimes, when God is teaching us, he will put us in the position where we have to be willing to give up something that is very dear to us, so that we can learn to put him first. If that thing is getting in the way, then he will either take it from us, or bring us to the very edge, where we come to the stage of saying “OK God, it’s yours, take it if you want.”
I suspect that this was the situation with Abraham. Isaac his son was the culmination of many years desire to have an heir. Isaac was his son through his loved wife Sarah, from their old age. Isaac was extremely precious to Abraham. But God had to get Abraham to value Him more highly than Isaac. This was only right, and would enable Abraham to continue to serve God, and to be able to teach Isaac to do the same.
So God told Abraham to sacrifice his son. A massive request. A request that would have driven Abraham into turmoil, but one that he came through and effectively said “OK God, I will do this, take him if you want.”
Mercifully, God came in at the last minute and gave his own substitute sacrifice of a lamb, prefiguring Jesus’ sacrifice for us all.
In Hebrews 11:17-19, the writer suggests that Abraham had faith in God that he would raise Isaac back from the dead if necessary. Though that is the case, Abraham’s willingness to kill Isaac was still a great test of Abraham’s dedication to God, not putting anything, even Isaac, before his relationship with his Creator.