What is an example of a nontrivial principal bundle whose fibre space $G$, total space $P$ and base space $M$ are compact connected manifolds (the fiber $G$ is a compact Lie group) such that $$H^*(P,\mathbb{Q})=H^*(G,\mathbb{Q})\otimes H^*(M,\mathbb{Q})$$

8$\begingroup$ Hatcher Corollary 4D.3 should provide examples if I am not mistaken. $\endgroup$ – Ulrich Pennig Jul 7 '20 at 15:53

7$\begingroup$ The examples pointed out by Ulrich Pennig are the bundles $U(n1) \to U(n) \to S^{2n1}$, $SU(n1) \to SU(n) \to S^{2n1}$, and $Sp(n1) \to Sp(n) \to S^{4n1}$ so one doesn't have to look far to find such examples. Imagine what Lie group theory would be like if all these bundles were trivial, so all these groups would be products of odddimensional spheres! $\endgroup$ – Allen Hatcher Jul 7 '20 at 21:44

2$\begingroup$ @AllenHatcher Thank you for adding the details. I was in a rush and did not have time to fill them in. $\endgroup$ – Ulrich Pennig Jul 7 '20 at 21:48
Let $P$ be any $SU(2)$bundle on $X$ with vanishing second Chern class $c_2(P)$. The hypotheses of the LerayHirsch theorem are satisfied if there is a class in $H^3(P)$ which restricts to the generator of $H^3(SU(2))$. This happens if and only if in the Leray spectral sequence, the map $d_3: H^0(X,H^3(SU(2))) \to H^4(X,H^0(SU(2))$ vanishes (since $H^i(SU(2))$ is concentrated in degrees $0$ and $3$, so the only nontrivial differentials are on the third page). This map is exactly the top Chern class.
There are nontrivial rank 2 complex bundles with vanishing Chern classes. The vanishing of $c_1$ implies that the $U(2)$ structure may be reduced to $SU(2)$, at which point the above argument shows that the hypotheses of LerayHirsch are satisfied.
Suppose $M = S^n$ is a sphere with $n$ odd and at least $5$. Pick your favorite Lie group $G$ for which $\pi_{n1}(G)$ is nontrivial. (Many examples may be found here. For example, for any $n > 3$, $G= SU(\frac{1}{2}(n1))$ works.) Since principal $G$bundles over $M$ are classified by $[M,BG]$ which is in bijection with $[S^{n1},G]$, there is a nontrivial principal $G$bundle.
Suppose $P\rightarrow M$ is any such nontrivial bundle. Then $H^\ast(P;\mathbb{Q})\cong H^\ast(G;\mathbb{Q})\otimes H^\ast(M;\mathbb{Q})$. One way to see this is to note that Borel showed the universal bundle $EG\rightarrow BG$ is totally transgressive: differentials originating on the fiber are trivial, except possibly when they land in the base. Thus, the same must be true in the bundle $P\rightarrow M$. But since the rational cohomology ring of $G$ is generated in odd degrees and $H^\ast(M;\mathbb{Q})$ is concentrated in odd degrees, all the differentials must vanish.
There is also a lowdimensional example. Consider the canonical map $\mathbb RP^3 \to \mathbb RP^{\infty} \to \mathbb CP^{\infty}$, classifying the unique nontrivial principal $S^1$bundle with base $\mathbb RP^3$. Its rational Serre spectral sequences collapses. Of course, its integral Serre spectral sequence does not collapse. The total space of this bundle is the 4manifold $E = S^1 \times_{\mathbb Z/2} S^3$ whose fundamental group is $\mathbb Z$, not $\mathbb Z \times \mathbb Z/2\mathbb Z$.