Psalm 44:21 (ESV)

21 would not God discover this? For he knows the secrets of the heart.

Wouldn’t God have discovered the people’s straying? He says it in a rhetorical question: of course God would have found out about that and discovered that. God knows our hearts (Psalm 139:1–24) and our deeds. He knows the secrets of our heart. See, for example, Jeremiah 11:20 reads, “But, O Lord of hosts, who judges righteously, who tests the heart and the mind, let me see…” But the writer did not stray from the way of the Lord. That is why we read the repeating question: why are you giving us over to our enemies? It is an honest and understandable question. We do not deserve punishment, why then this misery? It is a question of not understanding, perhaps a question out of despair.