(إِذْ يُرِيكَهُمُ اللَّهُ فِي مَنَامِكَ قَلِيلًا… ۖ) ([Remember, O Muhammad], when Allah showed them to you in your dream as few): This is called psychological preparedness. Allah (swt) showed the Prophet (saws) in his dream that the number of polytheists is few, even though they were three times more in reality.
(…وَلَوْ أَرَاكَهُمْ كَثِيرًا لَّفَشِلْتُمْ وَلَتَنَازَعْتُمْ فِي الْأَمْرِ…) (And if He had shown them to you as many, you [believers] would have lost courage and would have disputed in the matter [of whether to fight]): There would have been a state of anxiety and weakness, because the small Muslim army would not be able to confront the great number of the enemy, their power and weaponry. The Muslims then were a small group that possessed nothing to face a well-equipped group in every aspect. Had Allah (swt) shown them the reality of their enemies, there would have been failure and discord in the matter.
(…وَلَٰكِنَّ اللَّهَ سَلَّمَ ۗ إِنَّهُ عَلِيمٌ بِذَاتِ الصُّدُورِ) (But Allah saved [you from that]. Indeed, He is Knowing of that within the breasts.): He is All-Knowing of what is in the hearts, meaning what is within the chests. He (swt) knows the hidden secrets and the most concealed within the hearts. Allah (swt) willed to protect the Prophet (saws) and the believers who were with him, so that, this was a form of psychological preparation for this particular event. He (swt) also wills to depict for us the atmosphere of the first encounter and clash between the truth and falsehood.