If Alfonso XIII wanted to get the IF out of Russia one wonders why he didn't send a message to the Provisional government saying he would take them?
1. First, Alfonso XIII thought that they had been offered asylum in Britain.
2. When he discovered that was not the case (rather, that George V had gone back on his word) he did, but it was to late because the Imperial Family had already been sent to Siberia.
The sequence of events (I'm following Carlos Seco Serrano's book
Alfonso XIII:
1. The British Ambassador in Madrid,Hardinge, told the Spanish king that George V had offered asylum to the Imperial Family. That must have been at the end of March 1917 (after March 20).
2. Alfonso XIII received the new ambassador of the Provisional Government, Neklyudov, when he arrived in Madrid at the end of May 1917: "In your speech you have kindly mentioned my help to the Russian prisoner of wars. Now let me express my deep interest in other prisioners. I mean the Tsar Nicholas and his family. I beg you forward your government my request that they be freed". My guess is that at that time neither the Russian ambassador nor Alfonso XIII (100% certain regarding the king) knew that the Imperial Family had been refused asylum in Britain. If the Russian ambassador did, he did not tell the king.
3. The Imperial Family was sent to Siberia (31 July 1917).
4. Alfonso XIII tried again to make the British do something. "
Again Spain tried to "move" London to act regarding the august prisoners, proposing again the joint mediation of George V and Don Alfonso. Merry del Val, our ambassador, informed crudely to the Spanish Court that, while the British Royal Family was certainly worried for the Empress Dagmar (Marie), about whose fate nothing was known, on the other hand expressed their indifference towards Nicholas II's wife, Alix of Hesse. "The opinion about the latter (Alix) is very negative, in the palace as well as in the public opinion as a whole. She is seen as a conscious or unconcious German agent and as the main responsible for the revolution, for the bad advice she provided his husband, whom she completely controlled, avoiding that he granted the concessions that would have saved the throne... I have to add that this strong resentment against the Empress Alice exclude any possibility of her residing in the United Kingdom."
6. Bolshevik coup (7 November 1917). Kerensky goes into hiding.
7. Alfonso XIII asked the Norwegian and Swedish governments to try to get the release of the Imperial family from the Soviets, whereas he would send a ship of the Spanish Navy to any harbour of their countries to collect the the tsar and his family and bring them to Spain.
8. Brest-Litovsk treaty between the bolshevists and Germany (march 1918).
9. Nicholas II and his family are murdered in Ekaterinburg (17 July 1918)
7. Gomez Contreras, Spanish commercial attaché in Petrogado (the last Spanish diplomat to remain in the Soviet Union) received on 22 August 1918 orders to talk with the Soviets about the release of the Imperial Family (the orders had been cursed in July, but did not reach him till that date). Gomez Contreras went with the Dutch ambassador to Moscow, where they had two meetings with Chicherin, the Soviet Commissar of Foreign Affairs. Chicherin said that the Empress and the children were alive.
8. In November 1918 Gomez Contreras had to run away, crossing the Finnish border. He was murdered by the Communists in 1936 during the Spanish Civil War.
That is more or less the reconstruction I have made from 2 articles and a biography of Alfonso XIII I am reading. I'm afraid that is not 100% accurate regarding the dates, but I think that it shows that Alfonso XIII did everything that he could have done to save the Imperial Family, something that cannot be said about George V or Wilhem II.
Carlos Seco Serrano in his biography quotes from a book by Summer and Mangold "The file on the Tsar": "The most faithful and unfatigable friend that the Romanovs had during the despairing months of their captivity was the Spanish King Alfonso XIII".