See here.
Let $\pi$ be any group. Construct a connected CW complex $K(\pi, 1)$ such that $\pi_1(K(\pi, 1)) = \pi$ and $\pi_q(K(\pi, 1)) = 0$ for $q \neq 1$.
It is rarely the case that $K(\pi, 1)$ can be constructed as a compact manifold. What is a necessary condition on $\pi$ for this to happen?
There is a group of closely related necessary conditions on the homology and cohomology of $\pi$, in order for there to be a compact oriented $n$-dimensional manifold $K(\pi,1)$. Usually one fixes a choice of coefficient ring $R$, commutative and with unit element $1$. These conditions hold for any choice of $R$. (One can drop the "oriented" property but things get more complicated to state).
The simplest is that for any ring $R$ the groups $H^i(\pi;R)$ equal zero in dimensions $i>n$ and $R$ in dimension $i=n$.
Another one is that the twisted cohomology groups $H^i(\pi ; R \pi)$ (using the natural action of $\pi$ on $R\pi$) are zero in dimensions $i \ne n$ and $R$ in dimension $i=n$ (this one does not need the oriented condition).
The most subtle and important necessary condition is that $H_*(\pi;R)$ and $H^*(\pi;R)$, with cup and cap product structures, satisfy Poincare duality, meaning that $H^n(\pi;R)=R$ and is generated by an element $\xi$ having the property that the cap product with $\xi$ defines an isomorphism $H_i(\pi;R) \leftrightarrow H^{n-i}(\pi;R)$ for all $0 \le i \le n$. One says in this case that $\pi$ is a "Poincare duality group". In dimension 2 this condition is also known to be sufficient; in dimension 3 sufficiency is a major open question; in higher dimensions I am not an expert but I believe there are counterexamples to sufficiency.