So I know:
Let $G$ be a Lie group Given a smooth principal $G$ bundle $P \rightarrow M$, we may define an algebra homomorphism
$$I(G) \rightarrow H^{ev}(M; \Bbb R)$$ where $I(G)$ the graded algebra of real $G$- invariant polynomials.
Now I wish to define a homomorphism $$I(G) \rightarrow H^*(BG; \Bbb R) \quad (*) $$
The obstruction is that $BG$ is in general not a manifold. In Ebert's notes, page 143,144 Theorem 9.2.3 he claims that the remedy is to prove the result:
If $A$ is the set of natural transformations on the category of paracompact spaces $$Prin_G(-) \rightarrow H^*(-,\Bbb R)$$ $B$ is the set of natural transformations on the category of compact smooth manifolds, $$Prin_{G,C^\infty}(-) \rightarrow H^*(-,\Bbb R)$$ That the natural restriction from $A$ to $B$ yields a bijection, implies the existence of the homomorphism $(*)$.
How is this done?
Motivation for wanting to prove $\mathcal{A} \cong \mathcal{B}$:
Prof. Ebert really likes the perspective of "a $G$-characteristic class with values in $\mathbb{R}$ is a natural transformation from the functor $Prin_G(-)$ of isomorphism classes of principal $G$-bundles to the singular cohomology functor $H^*(-;\mathbb{R})$", which by bundle theory and the Yoneda Lemma is identified with an element of $H^*(BG;\mathbb{R})$. From this perspective $\mathcal{A}\cong\mathcal{B}$ says "You don't get new characteristic classes by restricting to smooth bundles over compact smooth manifolds, and you don't lose any either." In particular when $G$ is a Lie group you can construct elements of $H^*(BG;\mathbb{R})$ by only working with smooth $G$-bundles over compact smooth manifolds.
$\mathcal{A}\cong\mathcal{B} \implies$ Universal Cern-Weil homomorphism:
For any $p\in I(G)$, the Chern-Weil construction produces a natural transformation $\mathcal{I_p}\colon Prin_{G, C^{\infty}}(-) => H^*(-;\mathbb{R})$ over the category of compact smooth manifolds.
The theorem $\mathcal{A}\cong \mathcal{B}$ then implies $\mathcal{I_p}$ can be uniquely extended to a natural transformation$\mathcal{\tilde{I}}_p\colon Prin_{G}(-) => H^*(-;\mathbb{R})$ over the category of paracompact spaces, which contains a representing space for $Prin_G(-)$. Therefore $\mathcal{\tilde{I}}_p$ can be considered an element of $H^*(BG;\mathbb{R})$.
Then the function $I(G) \to H^*(BG;\mathbb{R})$ sends a $p\in I(G)$ to the natural transformation $\mathcal{\tilde{I}}_p$. The fact that it is a homomorphism follows from properties about the Chern-Weil construction that were proven earlier in the notes.
Seeing it more directly:
The geometric meat of the argument is contained in the proof that $\mathcal{A} \cong \mathcal{B}$, which like JHF points out is done by approximating $BG$ with compact smooth manifolds. Ebert gives a sequence of principal $G$-bundles $E_nG\to B_nG$ over compact smooth manifolds, along with inclusions $j_n\colon B_nG \to B_{n+1}G$ and functions $f_n\colon B_nG \to BG$ such that $f_n^* EG\cong E_nG$, $f_{n+1} \circ j_n \sim f_n$ and $$ f_n^*\colon H^i(BG) \to H^i(B_nG)$$ is an isomorphism for $n >> i$.
Now we can define the universal Chern-Weil homomorphism $CW_G$ in terms of these $f_n$'s. Given $p\in I(G)$ of homogeneous degree $d$ we chose an $n>>d$ and let $$CW_G(p) = (f_n^*)^{-1}\big(CW_{E_nG}(p)\big)\in H^d(BG)$$ where $CW_{E_nG}$ is the Chern-Weil homomorphism for $E_nG$. This is well-defined for $n$ sufficiently large because $f_{n+1}\circ j_n \sim f_n$.