Suppose $G$ is a Lie group, with $\pi_0(G)$ not necessarily finite, but might as well assume $G_0$, the connected component of the identity, is compact.
In the case that $\pi_0(G)$ is finite, then we know that there is an injection $H^*(BG,\mathbb{Q})\to H^*(BG_0,\mathbb{Q})$, and this can apparently be seen via a spectral sequence argument, using the fact that the rational cohomology of $B\pi_0(G)$ is concentrated in degree zero. So this is some kind of Leray–Serre spectral sequence argument on either $\pi_0(G)\to BG_0\to BG$ or $BG_0\to BG\to B\pi_0(G)$ (and I suspect the latter), probably using the degeneration and some kind of "edge homomorphism is injective" argument.
I suspect that in the case that we know something strong about the rational cohomology of $B\pi_0(G)$, then we might be able to say something in the case where $\pi_0(G)$ is not finite.
Unfortunately my spectral sequence knowledge is limited, and I can't find a treatment of spectral sequences that seems general enough to deal with this setup in general (namely non-simply-connected base, and possibly non-connected fibre, plus non-finiteness issues, depending on which fibration is used).
Is my intuition correct, that $H^*(B\pi_0(G),\mathbb{Q}) = H^0(B\pi_0(G),\mathbb{Q})$ can let us conclude something about how the cohomology of $BG$ relates to that of $BG_0$?
Also, what would be a good reference that covers a general-enough version of the relevant spectral sequence?