I was told there was a bijection between $[X;BG]$, the set of homotopy types of maps from a topological space $X$ to the classifying space $BG$, and the set of group homomorphisms $Hom(\pi_1 (X), G)$. But I wasn't able to find any information about this. What is the idea behind it? Could anyone give a reference?
What about, more generally, the relation between $[X,Y]$ and $Hom(\pi_1(X), \pi_1(Y))$? When is the map from left to right injective?