Here is a proof sketch using cohomological ideas. The argument is in four main steps:
I. General theory of families of Lie algebra homomorphisms.
II. The case of a semisimple $G$.
III. The case of a torus (here is a major gap in my argument)
IV. combining both cases.
A preliminary observation: if $H$ is the full linear group of a complex vector space, then the result is well-known, because up to conjugacy,
a homomorphism $G \to H$ is given by its character; and the set of characters is a discrete subspace of the space of all smooth maps
$G \to \mathbb{C}$.
I. For arbitrary Lie algebras, $Hom_{Lie -alg} (\mathfrak{g},\mathfrak{h})$ is a real algebraic variety and thus it is locally path-
connected. Therefore, nearby
homomorphisms can be connected by smooth families of homomorphisms (I am not entirely sure whether this is true, but it seems so).
Now consider a smooth family $f_t$, $t \in \mathbb{R}$, of Lie algebra homomorphisms. We study the problem of finding $h: \mathbb{R} \to H$
such that $f_t (X) = Ad (h(t)) f_0 (X)$ holds for all $t$ and $X \in \mathfrak{g}$. If $f_t$ is the derivative of a smooth family of group homomorphisms $\phi_t$,
then $h(t)$ conjugates $\phi_0$ to $\phi_t$ and thus solves the original problem.
Let $F_t$ be the derivative of $f_t$ with respect to $t$.
Differentiating the equation $[f_t X,f_t Y]=f_t [X,Y]$ shows that $F_t\in Hom (\mathfrak{g},\mathfrak{h})$ satisfies
$F_t ([X,Y])= [F_t (X);Y]-[F_t (Y);X]$. This means that $F_t$ is a $1$-cocycle in the Chevalley-Eilenberg complex for
$H^{\ast}(\mathfrak{g};f_t)$. By the cohomology I mean cohomology of $\mathfrak{g}$ with coefficients in $\mathfrak{h}$, viewed
as a $\mathfrak{g}$-module via $f_t$.
We can consider the collection of all Chevalley-Eilenberg complexes $C^{\ast} (\mathfrak{g},f_t)$ as a complex of
vector bundles on the real line; denote the vector bundles by $C^{\ast}(\mathfrak{g},f)$. The derivatives $F_t$ are a smooth family of $1$-cocycles and $[F_t]$ is a family of cohomology classes, smooth
in a certain sense. I say that $[F_t]$ is uniformly trivial if there is a smooth family $H_t$ of $0$-cochains such that $[f_t (X);H_t]=F_t (X)$ for all $t$ and
all $X \in \mathfrak{g}$ (this means that $d H_t =F_t$, but in a ''uniform way'').
Suppose that the cohomology class $[F_t]$ is uniformly trivial. Then
$$f_t (X) = \int_{0}^{t} F_s (X) ds = - \int_{0}^{1}[H_s;f_s (X)] ds;$$
in other words $f_t (X)$ solves the ODE $\frac{d}{dt} f_t (X) = - [H_t;f_t(X)]$ with initial value $f_0$. Another solution of the same ODE
is $Ad (h(t)) f_0(X)$, where $h(t) \in H$ solves $\frac{d}{dt} h(t)= H_t$. So $f_t$ is conjugate to $f_0$. Vice versa, if $Ad (h(t)) f_0(X)$,
then $[F_t]$ is uniformly trivial.
If $f_t$ is the derivative of a group homomorphism $G \to H$ and $G$ is compact, then pointwise triviality ($[F_t]=0$ for each $t$) implies uniform
triviality. This is by the preliminary observation, which implies that $d_0:C^0 (\mathfrak{g},f) \to C^1 (\mathfrak{g},f)$ has constant rank and so its image is a vector bundle (pass to the complexification of $\mathfrak{h}$, which is unproblematic as we are only interested in the dimension of the invariant subspace).
Thus we can pick a smooth $r: im (d_0) \to C^0 (\mathfrak{g},f)$ with $d_0 r = id$. Choosing $H_t:= r (F_t)$ solves the problem.
Thus we arrive at
THEOREM: ''If $f_t: \mathfrak{g} \to \mathfrak{h}$ is a family of homomorphisms of Lie algebras and $H$ a Lie group with Lie algebra $\mathfrak{h}$, then there is a
smooth map $h: \mathbb{R} \to H$ with $f_t = Ad (h(t))f_0$ if and only if the obstruction cocycle $[F_t]$ is uniformly trivial.''
ADDENDUM: ''If $G$ is a compact Lie group with Lie algebra $\mathfrak{g}$
and if $f_t$ is the derivative of a smooth family of homomorphisms $G \to H$, then pointwise triviality of $[F_t]$ implies uiform triviality.''
II.
Assume $G$ is semisimple. For each representation $V$ of
$\mathfrak{g}$, we have an isomorphism $H^{\ast} (\mathfrak{g};V) \cong H^{\ast} (\mathfrak{g};V^{\mathfrak{g}})$, because of the compactness of $G$.
But $H^1 (\mathfrak{g})=0$ since $G$ is semisimple, and so the cohomology class $[F_t]$ is zero, and by the addendum, it is uniformly trivial. Thus by the theorem,
nearby homomorphisms are conjugate if $G$ is semisimple.
III.
Assume $G=T$ is a torus (sketch). Let $V$ be the universal cover (equal to $\mathfrak{t}$) and $\Gamma \subset V$ be the kernel; this is a lattice.
Smooth families $f_t:\mathfrak{t} \to \mathfrak{h}$ are in bijection with smooth families $\psi_t: V \to H$ and induce families of group homomorphisms
$g_t: \Gamma \to H$. As Misha indicates, there is a parallel obstruction theory for such families; with an obstruction in $H^{1}_{group}(\Gamma;\mathfrak{h})$. Consult Weil's paper quoted in Mishas answer.
There is the Van Est isomorphism $H_{Lie}^{\ast} (\mathfrak{t},\mathfrak{h}) \cong H_{smooth} (V,\mathfrak{h})$ to smooth group cohomology and
furthermore a restriction $H_{smooth} (V,\mathfrak{h}) \to H^{\ast}_{group}(\Gamma; \mathfrak{h})$; this latter map is an isomorphism.
This isomorphism should map the corresponding obstructions onto each other (this is the part of the argument where I do not know the details).
So a family of group homomorphisms $V \to H$ is constant up to conjugacy iff the restriction to the lattice $\Gamma$ is constant up to conjugacy.
If the family $V \to H$ is the universal cover of a family $T \to H$, then the restriction to $\Gamma$ is constant; thus $T \to H$ is constant
up to conjugacy.
IV.
Consider an arbitrary compact $G$. Without loss of generality, we can pass to a finite
cover and thus assume $G=T \times K$, $T$ a torus and $K$ semisimple. Consider a family of group homomorphisms $\phi_t:G \to H$, with Lie algebra maps $f_t$ and
obstruction cocycle $F_t$ as above. By the solution of the problem for $T$, the restriction $F_t|_{\mathfrak{t}}$ is
uniformly trivial. But by the Künneth formula, the restriction $H^1 (\mathfrak{g} ) \cong H^1 (\mathfrak{k})\oplus H^1 (\mathfrak{t})\to H^1 (\mathfrak{t})$ is an isomorphism. Therefore,
$[F_t]$ is trivial and thus uniformly trivial, again by the addendum.
Afterthought: It is probably better to study the whole question in the context of smooth cohomology. A family $\phi_t:G \to H$ should give an obstruction class in $H^{1}_{smooth} (G; \mathfrak{h})$. If $G$ is compact, this space is trivial by invariant integration.