Define
$$G(t) = \int_0^t g(x)\,\mathrm dx.$$
Assuming $\lim_{t\to\infty} G(t)S(t)=0$ and writing $f(t) = -S^\prime(t)$ for the density function, integration by parts gives
$$H = \int_0^\infty g(t)S(t)\,\mathrm dt = G(0)S(0) + \int_0^\infty G(t) f(t)\,\mathrm dt.$$
(Notice $H$ is a number, not a function.)
If $X$ is a random variable with survival function $S(t) = \Pr(X \gt t),$ the right hand integral is related to the conditional expectation of $G(X)$ given that $X \ge 0$ because
$$E[G(X)\mid X\ge 0] = \frac{1}{1-S(0)} \int_0^\infty G(t)f(t)\,\mathrm dt = \frac{H - G(0)S(0)}{1-S(0)}.$$
In survival analysis, $X$ usually has non-negative support and (most often) $S(0)=0.$ In that case $H = E[G(X)]$ is the expectation of the integral of $g.$
The commonest practical application of this observation is to the case $g(t)=1,$ giving $G(X)=X.$ In that case $H = E[X]$ is a convenient expression for the expectation of a non-negative random variable.
The analysis at https://stats.stackexchange.com/a/222497/919 generalizes this result to any random variable, non-negative or not.