The Supreme Personality of Godhead, Mohini-murti, was able to bewilder all the demons, but Rahu was so clever that he was not bewildered. Rahu could understand that Mohini-murti was cheating the demons, and therefore he changed his dress, disguised himself as a demigod, and sat down in the assembly of the demigods. Here one may ask why the Supreme Personality of Godhead could not detect Rahu. The reason is that the Lord wanted to show the effects of drinking nectar. The moon and sun, however, were always alert in regard to Rahu. Thus when Rahu entered the assembly of the demigods, the moon and sun immediately detected him, and then the Supreme Personality of Godhead also became aware of him. When the Personality of Godhead, Mohini-murti, severed Rahu’s head from his body, the head remained alive although the body died. Rahu had been drinking nectar through his mouth, and before the nectar entered his body, his head was cut off. Thus Rahu’s head remained alive whereas the body died. This wonderful act performed by the Lord was meant to show that nectar is miraculous ambrosia.
Source: A.C. Bhaktivedanta Swami Prabhupada (2014 edition), “Srimad Bhagavatam”, Eighth Canto, Chapter 9 – Text 24 & 25