We can even add the hypothesis that $f$ and $g$ must be continuous
We first observe as Will did that if $f$ is $C^{1}$ then $g=-\dfrac{f^{^{\prime }}}{f}$
solves the question. Indeed, we have $\int_{0}^{+\infty }g\left( x\right) dx=%
\left[ -\ln f\right] _{0}^{+\infty }=+\infty $ and $\int_{0}^{+\infty
}f\left( x\right) g\left( x\right) dx=\int_{0}^{+\infty }-f^{^{\prime
}}\left( x\right) dx=f\left( 0\right) -f\left( +\infty \right) =f\left(
0\right) <+\infty $
If we manage to prove the existence of a $C^{1}$ function $\widetilde{f}$
such that $\forall x,$ $f\left( x\right) \leq \widetilde{f}\left( x\right) $
and $\widetilde{f}\left( x\right) \longrightarrow 0$ as $x\longrightarrow
+\infty $ then the result follows easily by taking $g=-\dfrac{\widetilde{f}%
^{^{\prime }}}{\widetilde{f}},$ as before we have $\int_{0}^{+\infty
}g\left( x\right) dx=\left[ -\ln \widetilde{f}\right] _{0}^{+\infty
}=+\infty $ and
$$
\int_{0}^{+\infty }f\left( x\right) g\left( x\right) dx\leq
\int_{0}^{+\infty }\widetilde{f}\left( x\right) g\left( x\right)
dx=\int_{0}^{+\infty }-\widetilde{f}^{^{\prime }}\left( x\right) dx<+\infty .
$$
Let $\varphi _{n}$ a smooth kernel verifying $\forall t\in
%TCIMACRO{\U{211d} }%
%BeginExpansion
\mathbb{R}
%EndExpansion
,$ $\varphi _{n}\left( t\right) \geq 0,$ $\varphi _{n}\left( t\right) =0$
for $|t|\geq \frac{1}{n},$ and $\int_{-\infty }^{+\infty }\varphi _{n}\left(
t\right) =1.$
We define $\tau f$ on $[1,+\infty \lbrack $by $\tau f\left(
t\right) =f\left( t-1\right) $ $\forall t$ and we extend it to a continous
function on $%
%TCIMACRO{\U{211d} }%
%BeginExpansion
\mathbb{R}
%EndExpansion
$ null on $]-\infty ,0]$ that we continue to denote by $\tau f.$
let $f_{n}$ defined on $%
%TCIMACRO{\U{211d} }%
%BeginExpansion
\mathbb{R}
%EndExpansion
$ by
$$
f_{n}\left( x\right) =\left( \tau f\ast \varphi _{n}\right) \left( x\right)
=\int_{-\infty }^{+\infty }\tau f\left( x-t\right) \varphi _{n}\left(
t\right) $$
Then $f_{n}$ is $C^{1}$ and we have for $x\geq 1$
$$f_{n}\left( x\right) =\int_{-1/n}^{1/n}\tau f\left( x-t\right) \varphi
_{n}\left( t\right) dt=\int_{x-1/n}^{x+1/n}\tau f\left( t\right) \varphi
_{n}\left( x-t\right) dt=\int_{x-1/n}^{x+1/n}f\left( t-1\right) \varphi
_{n}\left( x-t\right) dt $$
As $f$ is nonincreasing then
$$
f\left( x+\frac{1}{n}-1\right) \int_{x-1/n}^{x+1/n}\varphi _{n}\left(
x-t\right) dt\leq f_{n}\left( x\right) \leq f\left( x-\frac{1}{n}-1\right)
\int_{x-1/n}^{x+1/n}\varphi _{n}\left( x-t\right) dt $$
ie
$$
f\left( x+\frac{1}{n}-1\right) \leq f_{n}\left( x\right) \leq f\left( x-%
\frac{1}{n}-1\right) $$
Let $\widetilde{f}\left( x\right) =f_{2}\left( x\right) $ then we have $%
f\left( x\right) \leq f\left( x-\frac{1}{2}\right) \leq \widetilde{f}\left(
x\right) \leq f\left( x-\frac{3}{2}\right) $$
.
\widetilde{f}$ is positive and $\forall x\geq 2,$ $\widetilde{f}\left(
x\right) \leq f\left( x-2\right) $ hence $\widetilde{f}\left( x\right)
\longrightarrow 0$ as $x\longrightarrow +\infty $ and we have $\forall x,$ $%
f\left( x\right) \leq \widetilde{f}\left( x\right) .$