Why is there a judgement and angels recording our deeds if God already knows everything?
God needs neither the judgement nor the record in order to learn anything. Both exist for the sake of human beings. We are meant to see for ourselves that nothing is lost and that God's judgement is just.
It is a fair question. God knows everything, even what is most hidden. So the judgement is not meant to show Him anything new. It serves justice, and part of justice is that the one who is judged understands why. Here on earth too, many people deny what they have done or make excuses. A verdict is only truly just when no doubt remains.
That is why the Holy Qur’an describes a judgement in which a person's words are not the only thing that counts. Ears, eyes and skin will bear witness. This means that everything we do leaves a trace. It may fade, but it is never wiped out. Nature, too, preserves a great deal. Layers of rock and the light of distant stars carry traces of events from unimaginably long ago.
The two angels on the right and the left are not a picture of clerks with notebooks. They stand for a system God has placed within human beings, overseen by angels. When we do good, we feel ourselves grow and become nobler inside. When we do wrong, we sense that we have sunk a step lower. Both leave their mark on the soul, and that mark stays with us.
On the Day of Judgement this mark becomes visible. The verse above says that a person's own soul is enough to take account of him. He will see that God's knowledge was right and that he had deceived himself.
That God explains this system to us now is itself a mercy. It reminds us that no deed is lost, good or bad. Knowing this helps us live more consciously. And whoever sincerely repents may hope that God will turn the mark of wrongdoing into something good.