The Prophet ﷺ was leading the prayer at another masjid, and in his heart he wanted the qiblah to change, and he started looking up to the sky, in the hopes the qiblah changes, he did this 3/4 times and then this ayah was revealed.
This is a case where wahy was sent down during prayer, this is a unique attribute of our Prophet ﷺ.
The qiblah was changed by Allah with no reason other than to make the Prophet ﷺ happy.
He wanted this as this qiblah as the prophets before him also had the Ka’bah as their qiblah.
Prior to the Prophet ﷺ, the ka’bah was the home of 360 idols. And he came and cleansed the Ka’bah of the corruption of polytheism.
Qiblatan tardaaha: in qari tayyibs tafsir, he mentions that this could also mean the qiblah could have been made in any direction the Prophet ﷺ wanted.
In the previous books of the ahlul kitab that the qiblah was going to change.