If $\mathfrak{h}$ is perfect, then $\mathfrak{h}$ equals its own commutator subalgebra and hence is a derived algebra.
If $\mathfrak{h}=[\mathfrak{g},\mathfrak{g}]$ is solvable, then also $\mathfrak{g}$ is solvable, so that $[\mathfrak{g},\mathfrak{g}]$ is nilpotent. Then $\mathfrak{h}$ is nilpotent itself. For the nilpotent case we have still other obstructions. For some classes of nilpotent Lie algebras we can find an equivalent condition for the property that the given nilpotent Lie algebra is a derived algebra.
As an example, a filiform nilpotent Lie algebra is not a derived algebra if and only if it is characteristically nilpotent (i.e., all derivations are nilpotent) - for details see here:
Derived series of Lie algebra in reverse
In dimension $n\le 6$ every nilpotent Lie algebra is a derived Lie algebra. For dimension $7$, it is easy to find filiform characteristically nilpotent Lie algebras. They cannot be a derived Lie algebra.