For $X$ a $0$-connected nice space (say, a CW-complex), and for any group $G$, there is a natural bijection of the following shape

$$[X,BG]\simeq Hom(\pi_1(X),G)$$

which can be proved roughly as follows (if you like tannakian-like arguments):
maps from $X$ to $BG$ correspond to $G$-torsor over $X$, which correspond to maps of topoi from the topos of sheaves over $X$ to the topos of $G$-sets; but, as any $G$-torsor is locally constant, this also corresponds to the maps of topoi from the topos of locally constant sheaves over $X$ to the topos of $G$-sets. As, by Galois theory, the topos of locally constant sheaves over $X$ is canonically equivalent to the topos of $\pi_1(X)$-sets, we conclude from the fact that, given two groups $A$ and $B$, exact and colimit preserving functors from $B$-sets to $A$-sets correspond to homomorphisms of groups from $A$ to $B$.

To be precise, $[X,BG]$ means the set of homotopy classes of maps from $X$ to $BG$, while for $G$ an abelian group, $Hom(\pi_1(X),G)$ means the set of group homomorphisms (for a non abelian $G$'s, we have to quotient a little bit, but we won't care here).

For $A$ an abelian group, we thus get bijections
$$H^1(X,A)\simeq [X,BA]\simeq Hom(\pi_1(X)^{ab},A) .$$
By the Yoneda lemma, to prove that the map $\pi_1(X)^{ab}\to H_1(X,\mathbf{Z})$ is bijective, it is sufficient to prove that, for any abelian group $A$, the map
$$<\star> \quad Hom(H_1(X,\mathbf{Z}),A)\to Hom(\pi_1(X)^{ab},A)$$
is bijective. But, instead of checking this for all $A$'s, it is sufficient to prove this in the case where $A$ is an injective object in the category of abelian groups (because there are enough injectives). In this case, as $Hom(-,A)$ is an exact functor, we have a bijection
$$Hom(H_1(X,\mathbf{Z}),A)\simeq H^1(X,A) .$$
Therefore, for any injective $A$, the map $<\star>$ is bijective.

If you like topoi and pro-groups, you may play the same game and prove this for locally $0$-connected topoi with essentially the same argument.