Bereshit / Genesis 3:9 · Pshat
וַיִּקְרָא יְהוָה אֱלֹהִים אֶל־הָאָדָם וַיֹּאמֶר לוֹ אַיֶּכָּה׃
And the Eternal Almighty called to the human and said to him, "Where are you?"
Pshat פְּשָׁט
A question with a known answer
Sometimes you are asked about something the asker already knows. Why? The Almighty asks the first human "where are you", though He knows where he is. Rashi explains what such a question is for.
Rashi says: He knew where the human was, but wanted to enter into conversation with him, so that he would not be confused if punishment came suddenly. In the same way He opened conversations with Kayin (Cain), with Bilam (Balaam) and with Chizkiyahu (Hezekiah). Sforno reads the question literally: why are you not seen in the garden as before, for earlier you did not hide.
How Rashi and Sforno explain it
Rashi Where are you?
He knew where he was, but wanted to enter into conversation with him, so that he would not be confused in answering if He punished him suddenly (Bereshit Rabbah). So too He said to Kayin (Cain): "where is Hevel (Abel), your brother?" (Bereshit / Genesis 4), so too to Bilam (Balaam): "who are these men with you?" (Bamidbar / Numbers 22), to enter into conversation with them. So too with Chizkiyahu (Hezekiah) about the envoys of Merodach Baladan.
Sforno Where are you?
Why are you not seen in the garden as before? For now you have hidden, and earlier you did not do so.
Takeaway
Rashi points to the midrash in which the Almighty, before judging, asks the first human: "how did this happen to you?" (Bereshit Rabbah 19:9).
The three conversations Rashi brings: the question to Kayin "where is Hevel, your brother?" (Bereshit / Genesis 4:9), the question to Bilam "who are these men with you?" (Bamidbar / Numbers 22:9), and the prophet's question to Chizkiyahu about the envoys of the Babylonian king Merodach Baladan (Yeshayahu / Isaiah 39:3). In each the asker knows the answer.
Sforno reads "where are you" (אַיֶּכָּה) as a real question about place: the human hid for the first time, and is not seen where he always was.