I'm currently studying from the book of Loring Tu, 'Differential Geometry: Connections, Curvature and Characteristic classes', chapter 23.
This chapter is about the Chern-Weil homomorphism $$ c_E : \text{Inv} (\mathfrak{gl}(r, \mathbb{R})) \rightarrow H^{*} (M)$$ from the algebra $\text{Inv}(\mathfrak{gl}(r, \mathbb{R}))$ of invariant polynomials on $\mathfrak{gl}(r, \mathbb{R})$ to the de Rham cohomology algebra of $M$.
The way that these invariant polynomials are defined is: Let $X = [x^{i}_j]$ be an $r \times r$ matrix with indeterminate entries $x^{i}_{j}$. A polynomial $P(X)$ on $\mathfrak{gl}(r, \mathbb{R})$ is a polynomial in the entries of $X$. A polynomial $P(X)$ on $\mathfrak{gl}(r, \mathbb{R})$ is said to be $GL(r, \mathbb{R})$-invariant or simply invariant if $$ P(A^{-1} X A) = P(X)$$ for all $A \in GL(r, \mathbb{R})$.
The author gives $\text{tr}(X)$ and $\det(X)$ as examples of invariant polynomials on $\mathfrak{gl}(r, \mathbb{R})$.
My question is: is there any specific reason we consider polynomials on the Lie algebra $\mathfrak{gl}(r, \mathbb{R})$? Why not for example on the general linear group $GL(r, \mathbb{R})$? And does this have some generalizations to arbitrary Lie algebras?