Sheikh ibn Bāz rahimahullah further explains:
17 March 2024 • 1.78K views
The Prophet (peace be upon him) said to him: "What did your captive do?" He replied: "O Messenger of Allāh, he claimed that he will teach me such and such." The companions were most eager for knowledge and benefit. So, the Prophet (peace be upon him) said: "Indeed, he spoke the truth to you, while he is a liar." He spoke the truth with his statement: 'Whoever recites it (Ayātul Kursi) every night, Allāh will protect him, and the devil will not come near him.' However, he is a liar; in that he will come back. So, the conclusion is that the devil may teach a person some good due to reasons that necessitate it. He may even memorise a portion of the Qur'ān while being upon falsehood. Similarly, the disbeliever and the disobedient one may teach you something or benefit you with something while being malicious and doing so only for their own interests, either out of fear of Shirk or to draw benefit from you, as the devil did with Abū Hurairah. He ﷺ said: "Do you know, O Abū Hurairah, who you have been speaking to these nights?" I said: "No." He said: "Indeed, it is a devil," meaning a devil who has come in the form of a human. This provides us with benefits, such as: the devil may assume the form of a human, he may steal money, he may lie, and he may benefit. He may teach something beneficial, an Āyah or ḥadīth, which may benefit a person for his own interest. Benefit is something sought after, so if it comes from a disbeliever, if it is a good benefit, it is accepted.
Source:
https://binbaz.org.sa/audios/2578/3279