Suppose $G$ is a Lie group. In general, I think computing the cohomology ring of $BG$ is non-trivial, even when $G$ is simple compact Lie group. Of course, when $H^\ast(G;\mathbb{Z})$ is torsion free (e.g., $G = SU(n), Sp(n)$)), then it's not bad. But even for $G = Spin(n)$, it's non-trivial.
All that said, I think calculating $H^4$ is tractable.
Proposition: Suppose $G$ is a connected compact Lie group. Then $H^4(BG)$ is a free abelian group. Further, if $G$ is semi-simple, then the number of factors is precisely the number of simple factors of $G$.
Proof: First we'll show $H^4(BG)$ is free abelian. Since it's finitely generated, it's enough to show it's torsion free. From the universal coefficients theorem, the torsion in $H^4(BG)$ is isomorphic to the torsion in $H_3(BG)$.
We claim that $H_3(BG) = 0$. To that end, notice that $BG$ is simply connected since $G$ is connected, so by the Hurewicz theorem, the map $\pi_3(BG)\rightarrow H_3(BG)$ is surjective. However, $\pi_3(BG)\cong \pi_2(G) = 0$, as it is for every Lie group. Thus, we conclude $H^4(BG)$ is torsion free.
To count the number of factors, we use the rational Hurewicz theorem. The rational homotopy group $\pi_2(BG)\otimes \mathbb{Q} = 0$ because $\pi_2(BG)\cong \pi_1(G)$ is a finite abelian group (since $G$ is semi-simple). Since $\pi_3(BG) = 0$ as mentioned above, we see that $BG$ is rationally $3$-connected. The rational Hurewicz theorem then gives that the map $\pi_4(BG)\otimes \mathbb{Q}\rightarrow H_4(BG;\mathbb{Q})$ is an isomorphism. By universal coefficients, $H_4(BG;\mathbb{Q})\cong H^4(BG;\mathbb{Q})$ and by the homology universal coeficients, $H^4(BG;\mathbb{Q})\cong H^4(BG;\mathbb{Z})\otimes\mathbb{Q}$.
So, we conclude the dimension of $\pi_4(BG)\otimes \mathbb{Q}$ (as a rational vector space) is equal to the rank of $H^4(BG;\mathbb{Z})$.
Now, $\pi_4(BG)\cong \pi_3(G)\cong \pi_3(\tilde{G}))$ where $\tilde{G}$ is the universal cover of $G$. The universal cover splits into a product of simple simply connected Lie groups, and it is known that $\pi_3 \cong \mathbb{Z}$ for each of those. $\square$