Invariant polynomials on $\mathfrak{gl}(r, \mathbb{R})$ and characteristic classes 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? 
 A: Hopefully an expert will also share their thoughts, but one thing comes to my mind:
Keep in mind what you are going to use these invariant polynomials for: you are going to feed them the curvature 2-form of your connection in order to produce a real-valued $2k$-form.  The curvature is a Lie algebra-valued 2-form.  Why is it valued in the Lie algebra instead of the group?
An intuitive way to think about the connection as a Lie algebra valued 1-form $\omega$ is "if I parallel transport a vector an infinitesimally small amount in the tangent direction $X$, then with nearby tangent spaces identified I am rotating my vector by the infinitesimal amount $\omega(X)$."  So since "infinitesimal rotations" live in the Lie algebra and not the Lie group, it is necessary that the connection be Lie algebra-valued.  Then its curvature also ends up Lie algebra-valued, and so the polynomials that eat the curvature form must be polynomials on the Lie algebra.
As for generalizations, I don't trust myself to say anything about "arbitrary Lie algebras," but certainly when $\mathfrak{g}$ is the Lie algebra of a Lie group $G$ the theory has a generalization (and maybe some restriction is necessary on $G$, I wouldn't know).  The setting for that would be Chern-Weil theory applied to principal $G$-bundles.  A good reference is Dupont, Fibre Bundles and Chern-Weil Theory.
