Whatever be the motive, the Holy Prophet (SAW) was very keen to see the Ka’bah appointed as the Qiblah. Now, prophets are as close to Allah as man can ever be, and this exalted station teaches them to observe a very strict spiritual etiquette – they never submit a request before Allah until and unless they have received the permission to do so. This principle leads us to believe that the Holy Prophet (SAW) had already been allowed to pray for his wish to be fulfilled, and that he hoped his prayer would be granted. So, he used to turn his face again and again to the sky, anxiously waiting for an angel to appear and bring the injunction he had been wishing for.
In the present verse, Allah describes this state of the Holy Prophet (SAW) in an appreciative manner, and promises to assign him a Qiblah that he would like. Immediately after the promise, there follows the commandment
فَوَلِّ وَجْهَكَ شَطْرَ ٱلْمَسْجِدِ ٱلْحَرَامِ
“So turn your face towards the Sacred Mosque”
Here we find a manifestation of the subtle workings of divine grace – the Holy Prophet (SAW) was, to begin with, granted the joy of hearing a promise made, and, immediately after, the greater joy of seeing the promise fulfilled. (Qurtubi, Jaşsāş and Mazhari)
[Maarif ul Quran Vol-1 (pg 382-383) , Maktabah Dar al Uloom, Translation by Prof. Muhammad Hasan Askari & Prof. Muhammad Shamim]