If $G$ is a compact simply-connected simple Lie group, then any nontrivial homomorphism $G\to G$ is an automorphism (it is injective because $G$ is simple, and any immersion of closed connected manifolds of the same dimension is covering map), and in particular it has degree $\pm 1$. For example, if $f: S^3\to S^3$ is a map of degree $d$ with $|d|>1$, then $f$ is not homotopic to a homomorphism. On the other hand, by obstruction theory any self-map of an $n$-torus is homotopic to a map induced by multiplication by an $n\times n$ matrix with integer entries, which is a homomorphism.