Why was the Qiblah changed from Bayt al-Maqdis
    (Jerusalem) to the Ka’bah (Makkah)?
Question

                as-salaam-u-alikumI would like to know why Muslims once prayed towards bait-ul-muqadis and
      why was this changed to the ka'baa.jazakallah
Praise be to Allah.When the Prophet 
 (peace and blessings of Allaah be upon him) came
    from Makkah to Madeenah, he used to face Bayt al-Maqdis when he prayed, and that remained
    the case for sixteen or seventeen months, as is proven in the two Saheehs (al-Bukhaari and
    Muslim), in the hadeeth of al-Baraa ibn Aazib (may Allaah be pleased with him
    and his father), who said: The Prophet 
 (peace and blessings of Allaah be upon
    him) prayed towards Bayt al-Maqdis for sixteen or seventeen months, and he was hoping that
    the Qiblah would be towards the House (i.e., the Kabah)
Then after that Allaah commanded him to face the direction of the
    Kabah (the Sacred House), in the aayah (interpretation of the meaning): 
    so turn your face in the direction of al-Masjid al-Haraam (at Makkah). And wheresoever you
    people are, turn your faces (in prayer) in that direction [al-Baqarah
    2:144].
Before we answer the question about the wisdom behind this change, we must
    note the following points:
When we Muslims hear of a command from Allaah, we must accept it and
      submit to it, even if the wisdom behind it is not clear to us, as Allaah says
      (interpretation of the meaning): It is not for a believer, man or woman, when
      Allaah and His Messenger have decreed a matter, that they should have any option in their
      decision [al-Ahzaab 33:36]
Allaah, may He be glorified and exalted, does not give any command without
      there being great wisdom behind it  even if we do not understand it  as He
      says (interpretation of the meaning):  That is the judgement of Allaah. He
      judges between you. And Allaah is All-Knowing, All-Wise. [al-Mumtahinah 60:10]
Allaah, may He be glorified and exalted, does not abrogate any rule except
      to replace it with something better or similar to it, as He says (interpretation of the
      meaning): Whatever Verse (revelation) do We abrogate or cause to be forgotten, We
      bring a better one or similar to it. Know you not that Allaah is able to do all
      things? [al-Baqarah 2:106]
Having understood this, we may note that the wisdom behind the changing of
    the Qiblah has several aspects, including:
It is a test for the true believer, because the true believer, unlike
      others, accepts the commands of Allaah. Allaah has spoken of this in the Quraan
      (interpretation of the meaning):  And We made the Qiblah which you used to
      face, only to test those who followed the Messenger from those who would turn on their
      heels. Indeed it was great (heavy) except for those whom Allaah guided
      [al-Baqarah 2:143]
This ummah is the best of nations, as Allaah says (interpretation of the
      meaning): You are the best of peoples ever raised up for mankind
      [Aal Imraan 3:110]. Confirming the aayat about the Qiblah, Allaah says
      (interpretation of the meaning): Thus We have made of you (true Muslims) a Wasat
      (just) (and the best) nation [al-Baqarah 2:143]. Wasat
      conveys meanings of justice and of being chosen. So Allaah has chosen for this ummah
      goodness in all things and the best commands and rules, and thus He chose for them the
      Qiblah of Ibraaheem, upon whom be peace.
Imaam Ahmad reported in his Musnad (6/134-135) from
    Aaishah that the Prophet 
 (peace and blessings of Allaah be upon him) said
    about the People of the Book (Jews and Christians): They do not envy us for anything
    as much as they envy us for Yawm al-Jumuah (Friday), to which Allaah has
    guided us and from which they have gone astray, and for the Qiblah to which Allaah has
    guided us and from which they have gone astray, and for our saying Aameen
    behind the imaam. (For more information on this subject, please refer to Badai
    al-Fawaaid by Ibn al-Qayyim, may Allaah have mercy on him, 4/157-174).
    And Allaah knows best.