Very good question by the way. As a programmer, I have written programs that do exactly as I have created them to do. I do not "love" them. I do not have a relationship with them. They do not choose what to do, when to do it, how to do it ... I have them programmed to do EXACTLY as I designed them.
God could have made us like that. No choice, no will. No ability to do anything but exactly be in line with Him at all times.
God created Angels, and Men, with a capacity to decide, to think, to reason, and to make their own decisions. According to Ezekiel, Satan corrupted himself. Man, specifically Adam, as Eve wasn't even created yet, was given a choice, and a single command of God. "Do not eat of this tree.", and a set of consequences "It is the tree of knowledge of Good and evil" and "In the day you(singular) eat of it, you(singular) will die. (Kind of explains why Eve didn't get consequences for eating.)
So now we have it. We have God's command. We have Adam with full knowledge of God's command. We have Adam with the ability to choose to obey God, or not to obey God, and, without a knowledge of good and evil, this is the only "choice" that Adam has that can change his destiny.
Now think about this. Rewards and punishment and justice. Can I be just and punish you if you were knocked unconscious, someone put a gun in your hand, and pulled the trigger with the gun in your hand, killing someone else? Why or why not? No, right? It wasn't your "will" that executed the action that resulted in death. Someone else's will made it so that, even though the gun was in your hand, you weren't responsible for the action. You didn't kill anyone, nor did the gun. In this instance you would be just like the computer programs I write, executing commands that they have no choice but to follow.
Same with rewards. I cannot be just and reward you for something you had no part in doing as an act of will. Your choice has to be involved for just rewards to be given out. Otherwise, again, it is just like the computer program. It does as programmed. If I wrote it into a robot, and it did as I had programmed, would I seek to reward it? Do they reward the machines at automobile manufacturing plants? No. Ludicrous, right?
Now we all have a choice to seek out God, his truth, his will, and keep on seeking, proving, rightly dividing, examining ... to be sure that we have the truth and are doing what pleases God or we can just gather things we can use to prove our beliefs true and all opposing beliefs false and interpret everything in the light of our beliefs. We all have a choice as to how we respond to what we are given, and all of us have been given quite a lot. Rom. 1:18-32. We can all suppress, reject, exchange ... the truth of God, that He gives to each one of us, for a lie. We can refuse to accept a love for truth that exceeds our love for our beliefs, or we can seek God diligently and persistently for the rest of our lives, and be rewarded for our desire to know the truth about Him.
Again, acts of will produce rewards or punishment. If we choose to love Him, if we choose to seek Him, if we love truth more than any of our beliefs, we end up in a relationship with Him. It's not a relationship with robots without a choice. It's a relationship with those that choose to seek Him, to seek to understand Him, who want to be with Him, and live in accordance with all He thinks, believes, feels, wants, ... IF WE LOVE .... then we will keep His commandments. And we figure out what each and every one of them really says and means. And we have a relationship with our God.
Does this make sense?