All ibaadah, ultimately, is meant to please and draw closer to Allah (subhanahu wa ta'ala), and gaining knowledge is no different.
"Those who carry the Torah, but failed in that responsibility are like donkeys carry large burdens. How bad is the example of people who deny the Ayaat of Allah. And Allah doesn't guide the people who are wrongdoers." (62:5)
Their responsibility, before teaching, was to learn what they were teaching ("carrying" in this verse). Change was supposed to take root first and foremost in their own hearts before they called others to it. The action of gaining and spreading knowledge, by this principle, becomes sincere or insincere.
Imam Ibn Qayyim Al-Jawziyyah said, under the heading "The Cure to Ignorance is Questioning," "This encompasses the diseases of the heart, the soul, the body, and their cures." He cites a hadith, in which a man was wounded and, when it came time to do wudhoo, his companions said that he had to use water. He died, and Rasoolullah (sallallahu 'alayhi wa sallam) heard about this, and responded, "They [the companions of the man] killed him...Don't they ask when they don't know? The only cure for ignorance is questioning."
However, in another hadeeth, Rasoolullah (SAW) said, "The most sinful person among the Muslims is the one who asked about something which had not been prohibited, but was prohibited because of his asking."
The former hadeeth was based on a desire to ask questions strictly for the sake of gaining knowledge, whereas the latter was likely based on stubbornness, much like the questioning of the Children of Israel when they were commanded to slaughter a cow (2:68). Another hadeeth speaks about people who came before the Muslims who were ruined because of their excessive questioning.
Imam Ibnul Jawzi, in his Saydul Khaatir, under the chapter, "The Ulamaa who Worked," wrote about his experiences of those who worked on the basis of their knowledge - and those who didn't.
He found the most beneficial scholars for him to sit with were those who applied what they knew, even though they knew less than the more knowledgeable. About Abdul-Wahhab Al-Anmaati, he said, about the tears that Al-Anmaati shed while Ibnul Jawzi read him ahaadeeth, "His tears affected my heart."
Another characteristic that he mentioned was the hesitancy of answering a question about a religious matter. He mentions Abu Mansur Al-Jawaaliqi, who was very quiet, and would even hesitate about answering the easiest ones, for fear that he'd make a mistake.
On the other hand, Imam Ibnul Jawzi said, "I met a group from the people of hadeeth who memorized and knew a lot, however they would permit backbiting under the guise of jarh wa ta'deel [warning against taking ahaadeeth from people], they would take monetary payment in return for narrating hadeeth, and they would be hasty in giving answers, even if they are wrong, lest their status diminishes."
The signs that he mentioned are signs of corruption, signs of scholars who learned for the wrong reasons. However, the sincere scholar restrains his tongue, even when answering a question, and restrict access to ahaadeeth when they "take monetary payment in return for narrating [them]." This is a sign of one who has gained knowledge for the sake of pleasing Allah (subhanahu wa ta'ala).
Ibnul Jawzi closes this chapter in his book by saying, "[G]uiding people by one's action is more inspiring than doing so by words. So...Allah, one should implement what he knows for it is indeed the greatest foundation. And the miskeen [poor person], the true miskeen is the one who wasted his life learning what he does not practice, thus he looses the pleasures of the dunyah and the goodies of the akhirah. (In addition to) Coming forth bankrupt (on the day of judgment) with strong evidences against himself."