Another argument which does it:
A path connected based space $X$ is a co-$H$ space if and only if the evaluation map $\Sigma \Omega X \to X$ admits a section up to homotopy. This will imply that $\pi_1(X)$ is a retract of $\pi_1(\Sigma \Omega X)$, and it's easy to see that the latter has a free fundamental group (generated by elements of $\pi_1(X)$). Now use the fact that a subgroup of a free group is free.
The rest of the argument goes as Jeff says: the fundamental group of an $H$-space is abelian.
Addendum
If in addition $X$ has the homotopy type of a finite complex, then the existence of an $H$-space structure implies that $X$ satisfies Poincare duality (this is well-known and can be deduced from the structure theorem for connected Hopf algebras; I also gave an independent proof in one of my papers--I can't remember which one).
On the other hand, since $X$ is also co-$H$, there are no non-trivial cup products of classes in positive degrees.
If we combine these two statements (duality + no cup products) we infer that $X$ has cohomology concentrated in degrees $0$ and some integer $n$. If $X$ isn't a contractible, it follows from duality that $n > 0$ and $H_n(X) = \Bbb Z$. It follows that $X$ is a cohomology $n$-sphere. Since $X$ is an $H$-space it is a simple space, so $X$ is then a homotopy $n$-sphere.
Thus we've shown:
Theorem: If $X$ is both an $H$-space and a co-$H$ space and has the homotopy type of a connnected finite complex, then $X$ has the homotopy type of a point or an $n$-sphere ($n >0$).