Whereas ordinarily χάριν εἰδέναι (τινί) is an idiom that means "to thank (someone)" (LSJ: "to acknowledge a sense of favour, feel grateful"), the passage from Aristotle that you cite (Metaphysics A, 982a15) makes the infinitive εἰδέναι into a noun with the definite article τοῦ, so that the whole phrase τοῦ εἰδέναι χάριν comes to mean "for the sake of (the) knowing": καὶ τῶν ἐπιστημῶν δὲ τὴν αὑτῆς ἕνεκεν καὶ τοῦ εἰδέναι χάριν αἱρετὴν οὖσαν μᾶλλον εἶναι σοφίαν ἢ τὴν τῶν ἀποβαινόντων ἕνεκεν, "... and of the sciences, the one that is for its own sake and for the sake of knowledge is a wisdom more to be desired than the science that is for the sake of its results."
An aside: this thought was a founding principle of 'Atenisi (Athens) University in the Kingdom of Tonga (South Pacific).