Background of the verse
Allah allowed Adam and Hawwa (peace be upon them) to live in Paradise and forbade them to go near one tree. Satan swore oaths to deceive them, claiming the tree would make them live forever or become angels, so both of them ate from it. When Allah called them and reminded them that Satan was their open enemy, they made no excuses but at once made this dua. The story is told in Surah Al-Baqarah, Surah Al-A'raf and Surah Ta-Ha, and Surah Ta-Ha says that his Lord then chose him, accepted his repentance and guided him.
Meaning of the verse
English translation of Rabbana zalamna anfusana: "Our Lord! We have wronged ourselves. If You do not forgive us and have mercy on us, we shall certainly be among the losers." This dua has three parts: first, a clear admission of the mistake, that we harmed our own selves; second, a request for forgiveness, which wipes out past sin, and for mercy, which grants good in the future; third, the awareness that without Allah's forgiveness a person's end is loss.
Surah Al-Baqarah verse 37 says that Adam received certain words from his Lord, and Allah accepted his repentance. According to a large group of the scholars of tafsir, those words are this very dua, because the Quran itself gives these words of their dua.
The difference between Adam and Iblis
The Quran describes the outcome of two acts of disobedience side by side. When Iblis refused the command, he was arrogant, blamed his mistake on destiny and stubbornly chose rebellion instead of repentance. When Adam (peace be upon him) forgot and slipped, he humbly admitted his fault and asked his Lord for forgiveness. That is why Iblis was rejected forever and Adam was chosen. The lesson for every person is that, after a sin, what really decides things is whether the servant takes the path of admission and repentance or of excuses and stubbornness.
When and how to recite it
This dua can be recited at any time, without a set time or number, whenever one is conscious of a sin or shortcoming. No authentic hadith fixes any special number or wird (set recitation) for it, so practices with a specific count have no evidence. The Prophet ﷺ taught Abu Bakr al-Siddiq (may Allah be pleased with him) a dua with a similar meaning to say in prayer, recorded in Sahih al-Bukhari: "Allahumma inni zalamtu nafsi zulman kathiran wa la yaghfiru al-dhunuba illa anta" (O Allah, I have wronged myself greatly, and none forgives sins except You).
A report is very popular among people that Adam (peace be upon him) asked for forgiveness through the intermediary of the Prophet ﷺ and had seen his name written on the Throne. Hadith scholars have graded it very weak, and Imam al-Dhahabi (may Allah have mercy on him) and others have even called it fabricated. The words of Adam's dua given by the Quran are these very words, in which forgiveness and mercy are asked directly from his Lord alone.