There are three kinds of knowledge according to the Quran: useful knowledge, harmful knowledge and one that is neither useful nor harmful.
Learning useful knowledge is so important that Prophet Moses (AS) sought to find a guide and master for that, and when he found Khidr, Moses asked that he teach him a knowledge that would lead to his growth and progress: “Moses said to him: ‘May I follow you so that you can teach me of that you have learned of righteousness?’” (Surah Al-Kahf, verse 66)
Also in verse 259 of Surah Al-Baqarah, we read about Prophet Uzair who went to sleep for one hundred years to experience what the return of the dead to life is: “(Or have you heard) of the one who, on passing through an empty and ruined town, said, "When will God bring it to life?" God caused him to die and brought him back to life after a hundred years and then asked him, "How long have you been here?" He replied, "One day or part of a day." The Lord said, "No, you have been here for one hundred years. Look at your food and drink. They have not yet decayed. But look at your donkey and its bones. To make your case evidence (of the Truth) for the people, see how we bring the bones together and cover them with flesh." When he learned the whole story, he said, "Now I know that God has power over all things.”
In the next verse, God urges Abraham (Ibraheem) to kill four birds and see how God returns them to life: “And (remember) when Abraham said: ‘Show me, Lord, how You raise the dead,’ He replied: ‘Have you not believed?’ ‘Rather,’ said Abraham, 'in order that my heart be satisfied.’ ‘Take four birds, ' said He, 'draw them to you, then set a part of them on every hill, then call them, they will come swiftly to you. Know that Allah is Mighty and Wise.’”
The Holy Quran also refers to knowledge that is not useful or is harmful. For example it highlights the example of those who are seeking harmful knowledge: “Indeed, they learned what harms them and does not profit them.” (Surah Al-Baqarah, verse 102)
The Quran also forbids asking questions whose answer could have negative consequences: “Believers, do not ask about things that if they appeared to you, would only upset you.” (Surah Al-Maidah, verse 101)
As for seeking knowledge that is neither useful nor harmful, the Quran mentions an example in Surah Al-Kahf, verse 22: “Some will say: 'They were three; their dog was the fourth. 'Others, guessing at the Unseen, will say: 'They were five and their dog was the sixth. 'And yet others: 'Seven; their dog was the eighth. 'Say: 'My Lord knows best their number. Except for a few none know their number. 'Therefore, do not dispute with them except in outward disputation, and do not ask any of them concerning them.”
There is a Hadith narrated from the Holy Prophet (PBUH) who said, “I seek refuge (with God) from … knowledge that is of no benefit.”