We are not to assume that God did not know where Adam was and what he had done. Rather this was the voice of God wanting to have fellowship with his creatures.
The meaning of this question has been summarised by Griffith Thomas: ‘God’s question to Adam still sounds in the ear of every sinner: “Where art thou?” It is the call of Divine justice, which cannot overlook sin. It is the call of Divine sorrow, which grieves over the sinner. It is the call of Divine love, which offers redemption from sin. To each and to every one of us the call is reiterated.’
The picture of a seeking God is one of the most attractive given of him in the Bible. Think of how Jesus described himself as the seeking Shepherd. He described his mission as to seek and to save that which is lost. There are many pictures of God in the Bible, but this one of him seeking Adam in Eden is a foretaste of others in the Bible that will magnify his love.
The story gives another picture of God, that of him functioning as interrogator as he cross-examines each of the creatures before him. How careful he searches, how penetrating are his questions. He is here as judge of the rebels. They may want to escape but they cannot. This is a foretaste of his future role on the Day of Judgment when each one of us will give an account to God.
But the story gives a further picture of God. He is not only the seeker and the interrogator, he is also the provider of deliverance for sinners. We see this in the pronouncement made to Satan that one will come, a member of the human race, who will undo the disaster brought about by the devil. A Champion will come who will suffer in the process, which is a wonderful description of the sufferings that Jesus endured on the cross.
A fourth picture is given in verses 22 to 24, where God appears as the Banisher of Adam and Eve from the garden. It seems that Adam was very reluctant to leave the garden because he had to be driven out. But he had to be because the blessings of the garden now became a source of danger. The one that is identified is the tree of life, which had been a symbol of eternal life. God had promised that if a person had eaten of that tree, he would not die. God never reneges on a promise, but sometimes sin brings about a situation that would not be good if the promise was kept. Therefore God ensured that Adam would have no access to the tree of life. He banished him from the garden so that he would be able to have mercy upon him. The banishment was protection from eternal punishment.
So we can say that in the garden God was the seeking God, the probing God, the providing God and the protective God.