If $G$ is an algebraic group, then one can show $\operatorname{H}^*(BG,k)$ and $\operatorname{H}_*(G,k)$ are Koszul dual dg algebras, e.g. Drinfeld and Gaitsgory, "Finiteness questions for algebraic stacks", (7.2). Basically you write $G$ as a pullback of two copies of the trivial map $\mathrm{pt}\to BG$ and use sheaf theory and base change. For this the group should be locally of finite type and characteristic zero.
E.g. the cohomology of $B\mathbf{G}_m$ and $\mathbf{G}_m$ are freely generated in degrees $2$ and $1$, respectively.
Is there a concise proof of this fact in topology (where I think it was first discovered)? Something that is different from the sheaf theory argument. For instance, does it follow more or less formally from writing $\operatorname{H}^*(BG,\mathbf{Q})=\operatorname{Maps}(BG,H\mathbf{Q})$?
Second, for what sort of topological groups is this theorem true? There are lots of topological spaces not coming from the above sorts of algebraic groups, e.g. mapping spaces $\operatorname{Maps}(X,G)$ for $X$ a topological space.