Which homotopy 2-types are H-spaces? Let $X$ be a connected CW-complex with $\pi_k(X)$ trivial for $k >2$. Is it known under which circumstances $X$ is an $H$-group?
I have been able only to deduce the necessary condition that $\pi_1(X)$ has to be abelian and act trivially on $\pi_2(X)$. Furthermore, if the necessary condition holds, vanishing of the Postnikov invariant $\beta \in H^3( \pi_1(X), \pi_2(X))$ is a sufficient condition. Thus the interesting case is that of $\beta$ nonzero.
 A: I just wanted to add to Tyler Lawson's answer that all the maps $\beta\colon K(G,1)\rightarrow K(A,3)$ ($G$ and $A$ abelian and no action of $G$ on $A$) satisfying his additivity condition are loop maps by Stasheff's Homotopy Associativity of $H$-Spaces II (Theorem 5.3). Hence for 2-types being an $H$-space is the same as being a loop space. See also Qiaochu Yuan's comment.
In terms of $k$-invariants, the condition is that the $k$-invariant of the 2-type is in the image of the so-called cohomology 'suspension' morphism
$$H^4(K(G,2),A)\longrightarrow H^3(K(G,1),A),$$
which is induced by taking loops on the corresponding sets of homotopy classes of maps between Eilenberg-MacLane spaces.
The source is very well understood, it coincides with
$$\hom(\Gamma(G),A).$$
Here $\Gamma(G)$ is the target of the universal quadratic map $G\rightarrow\Gamma(G)$. Recall that a map $\gamma\colon G\to B$ between abelian groups is quadratic if $G\times G\to B\colon (x,y)\mapsto\gamma(x+y)-\gamma(x)-\gamma(y)$ is bilinear.
An example with non-trivial $k$-invariant can be constructed as follows. It suffices to show that
$$H^4(K(\mathbb{Z}/2,2),\mathbb{Z}/4)\longrightarrow H^3(K(\mathbb{Z}/2,1),\mathbb{Z}/4)$$
coincides with
$$\mathbb{Z}/4\twoheadrightarrow \mathbb{Z}/2.$$
Indeed, $H^3(K(\mathbb{Z}/2,1),\mathbb{Z}/4)$ is well-known to be the elements annihilated by $2$ in $\mathbb{Z}/4$, which identifies with $\mathbb{Z}/2$. A normalised $3$-cocycle representing the generator is
$$f\colon \mathbb{Z}/2\times \mathbb{Z}/2\times \mathbb{Z}/2\longrightarrow \mathbb{Z}/4,\qquad f(1,1,1)=2.$$
(I will omit notations for classes in quotients of $\mathbb{Z}$ since the meaning in each case will be clear from the context.)
The universal quadratic map for $\mathbb{Z}/2$ is $\gamma\colon \mathbb{Z}/2\rightarrow \mathbb{Z}/4$, $\gamma(0)=0$, $\gamma(1)=1$. Hence $\Gamma(\mathbb{Z}/2)=\mathbb{Z}/4$ and
$$\hom(\Gamma(\mathbb{Z}/2),\mathbb{Z}/4)=\hom(\mathbb{Z}/4,\mathbb{Z}/4)=\mathbb{Z}/4.$$
In order to compute the suspension morphisms I'm going to use crossed modules and their semi-stable version called reduced quadratic modules by Baues (see his book on 4-dimensional complexes). It is well known that 3-dimensional group cohomology classifies crossed modules (Eilenberg-MacLane or one of them alone, I don't currently remember). Similarly $\hom(\Gamma(\mathbb{Z}/2),\mathbb{Z}/4)$ classifies reduced quadratic modules. The generator is represented by the reduced quadratic module
$$\mathbb{Z}\otimes \mathbb{Z} \stackrel{\langle-,-\rangle}\longrightarrow \mathbb{Z}\oplus \mathbb{Z}/4\stackrel{\partial}\longrightarrow \mathbb{Z}$$
where $\partial(a,b)=2a$ and $\langle x,y\rangle =(0,{xy}).$ This is because $\ker \partial=\mathbb{Z}/4$, $\operatorname{coker}\partial=\mathbb{Z}/2$ and the map $\mathbb{Z}/2\mapsto \mathbb{Z}/4$ defined by ${x}\mapsto{\langle x,x\rangle}$ coincides with the aforementioned universal quadratic map. The loop crossed module of this reduced quadratic module is
$$\mathbb{Z}\oplus \mathbb{Z}/4\stackrel{\partial}\longrightarrow \mathbb{Z},$$
where the source is equipped with an exponential action of the target defined by
$$x^a=x+\langle\partial(x),a\rangle.$$
(Crossed modules usually consist of non-abelian groups and reduced quadratic modules too, but in this case everything is abelian because they are very small, this simplifies a lot the computations). A 3-cocycle
$$g\colon \mathbb{Z}/2\times \mathbb{Z}/2\times \mathbb{Z}/2\longrightarrow \mathbb{Z}/4$$
representing the cohomology class of this crossed module is defined by the following choices:
We first need a set-theoretic splitting of $\partial$, that we define as
$$s\colon \mathbb{Z}/2\longrightarrow \mathbb{Z},\qquad s(0)=0,\quad s(1)=1.$$
Now, for each pair of elements $x,y\in \mathbb{Z}/2$ we need $t(x,y)\in \mathbb{Z}\oplus \mathbb{Z}/4$ such that
$$\partial(t(x,y))=-s(y)-s(x)+s(x+y).$$
This measures the failure of $s$ to be a morphism.
We take $t(0,-)=(0,0)$, $t(-,0)=(0,0)$, and $t(1,1)=(1,0)$.
With these choices $g$ is
$$g(x,y,z)=t(x,y)^{s(z)}+t(x+y,z)-t(x,y+z)-t(y,z)\in\ker\partial=\mathbb{Z}/4.$$
Different choices produce cohomologous cocycles.
This cocycle is normalised because $t(0,-)$ and $t(-,0)$ vanish, so we only have to compute
$$\begin{array}{rcl}
g(1,1,1)&=&t(1,1)^{s(1)}+t(1+1,1)-t(1,1+1)-t(1,1)\\
&=&t(1,1)+\langle \partial t(1,1), s(1)\rangle +t(0,1)-t(1,0)-t(1,1)\\
&=&\langle \partial t(1,1), s(1)\rangle\\
&=&\langle \partial (1,0), 1\rangle\\
&=&\langle 2, 1\rangle\\
&=&(0,2).
\end{array}$$
The second coordinate (the kernel of $\partial$) is $2\in \mathbb{Z}/4$, therefore, $g=f$ above. This concludes the proof of the claim.
A: The necessary condition is a "additivity"-type condition on the $k$-invariant.
Suppose $\pi_1 X = G$ and $\pi_2 X = A$. As you correctly point out, $G$ must be abelian and act trivially on $A$. Under these circumstances, the $k$-invariant is expressible as a natural map of pointed spaces
$$
\beta: K(G,1) \to K(A,3).
$$
(Normally $\beta$ can only be constructed as a map $K(G,1) \to K(A_G, 3)$ in terms of the coinvariants.) The space $X$ is the homotopy fiber of $\beta$, and the $k$-invariant of $X \times X$ is $\beta \times \beta$.
This means that, in order to get an $H$-space, it is necessary and sufficient to get a homotopy commutative diagram of pointed spaces:
$\require{AMScd}$
$$
\begin{CD}
K(G,1) \times K(G,1) @>m>> K(G,1)\\
@V \beta \times \beta V V @VV \beta V\\
K(A,3) \times K(A,3) @>>m> K(A,3)
\end{CD}
$$
Here $m$ is the $H$-space multiplication on Eilenberg--Mac Lane spaces for abelian groups, which induces addition on cohomology. In terms of the projection maps $p_i: K(G,1) \times K(G,1) \to K(G,1)$, homotopy commutativity of this diagram says that
$$
m^*(\beta) = p_1^*(\beta) + p_2^*(\beta).
$$
If there is a sufficiently good Kunneth formula (e.g. if $A$ is a ring and $H_*(K(G,1);A)$ are finitely generated projective) then $m^*$ is a "coproduct"
$$
m^*: H^*(K(G,1); A) \to H^*(K(G,1); A) \otimes_A H^*(K(G,1); A)
$$
and under this identification we are asking that $\beta$ is primitive: $m^*(\beta) = \beta \otimes 1 + 1 \otimes \beta$.
If we think of $\beta$ as representing a cohomology operation $H^1(-;G) \to H^3(-;A)$, this condition equivalently asks that $\beta$ is additive: $\beta(x + y) = \beta(x) + \beta(y)$.
