I found this hadith but I'm confused why they will ask question. If Allah(S.W.A) knows everything about us. This is hadith "The two angels who are charged with questioning come to him and ask him what he used to believe in in this world, who was his Lord, what was his religion and who was his Prophet.If he gives a good answer, that is good, but if he does not answer them they inflict a severe and painful beating on him. "
Why will someone be punished based upon these questions??