How to attain Sincerity in seeking knowledge In’Shaa’Allaah: Firstly, your intention should be to fulfill Allaah’s Command
Imaam Muhammad Ibn Saaleh Al-Uthaymeen (rahimahullaah) said: If one says: Through what can sincerity in seeking knowledge be (attained)?
We say: Sincerity in seeking knowledge can be (attained) by making an intention for the following: Firstly: (The intention) to fulfil Allaah’s command because Allaah (The Most High) commanded it (i.e. to seek knowledge). Allaah said: [فَاعْلَمْ أَنَّهُ لَا إِلَٰهَ إِلَّا اللَّهُ وَاسْتَغْفِرْ لِذَنبِكَ- So know (O Muhammad) that La ilaha ill-Allah (none has the right to be worshipped but Allah), and ask forgiveness for your sin’’ (Surah Muhammad Ayah19)].
So Allaah (Glorified and Exalted Be He) strongly urged (a person) towards acquiring knowledge. And strongly urging (someone) towards something necessitates having love for it; being pleased with it and commanding (one) to do it.
[Sharh Hilyah Taalib Al’Ilm’ page 16. Slightly paraphrased]