You need to combine two classical theorems:
- if $K$ denotes the compact form of $G$, then $K \to G$ is a homotopy equivalence; this is discussed in Bröcker-tom Diecks book "Representations of compact Lie groups", in the section with "complexification" in the title. So $H^* (BG)=H^*(BK)$.
- The Chern-Weil homomorphism $CW : Sym^* (\mathfrak{k}^*)^K \to H^* (BK;\mathbb{R})$ (which exists for an arbitrary Lie group $K$ with Lie algebra $\mathfrak{k}$) is an isomorphism for compact groups, this goes back to Borel or Cartan (?). This theorem is discussed and proven in Dupont's beautiful book "Curvature and characteristic classes" (there you find the construction of $CW$ as well, in case you do not now it already).