I think it much more convincing to note that $\{f < 0\} = \cup_{n=1}^\infty \{f \leq -n^{-1}\}$. Suppose that $\alpha_n = \mu(\{f \leq -n^{-1}\}) > 0$ for some $n \geq 1$; then $$\int_{\{f \leq -n^{-1}\}} f d\mu \leq -n^{-1}\alpha_n < 0,$$
a contradiction to the hypothesis since $f^{-1}(-\infty,-n^{-1})$ is the pre-image of a Borel set, hence measurable. Thus $\alpha_n = 0$ for all $n \geq 1$, and $$\mu(\{f < 0\}) \leq \sum_{n=1}^\infty \alpha_n = 0.$$
Let $F(x):=\int_0^xg(t)\,dt$. Then, $F$ is AC on $[0,1]$ with $F'=g$ a.e. Note that for any $\phi\in C^{\infty}([0,1])$ which vanishes at the endpoints, we can integrate by parts (why is it applicable here?) to get
\begin{align}
\int_0^1F(t)\phi'(t)\,dt&=-\int_0^1F'(t)\phi(t)\,dt=-\int_0^1g(t)\phi(t)\,dt=\int_0^1f(t)\phi'(t)\,dt.
\end{align}
Hence, $F$ and $f$ agree up to a constant. Therefore, we have shown that $f$ equals a function ($F$ plus a constant) which is AC on $[0,1]$ that has a.e derivative $g$.
This final assertion that $F$ and $f$ agree up to a constant is a consequence of the following lemma:
If $h\in L^1([a,b])$ and for all smooth $\phi$ vanishing at endpoints we have $\int_a^bh(t)\phi'(t)\,dt=0$, then $h$ equals a constant a.e (namely its average $\frac{1}{b-a}\int_a^bh(t)\,dt$).
Here is one possible proof. Note that neither our hypotheses nor our conclusion is affected if we add a constant to $h$. Hence, by subtracting off the average from $h$, we may as well assume $\int_a^bh(t)\,dt=0$. Now, let $\psi$ be any smooth function on $[a,b]$, consider $\tilde{\psi}=\psi-\frac{1}{b-a}\int_a^b\psi$, and define $\phi:[a,b]\to\Bbb{R}$ as $\phi(x):=\int_a^x\tilde{\psi}(t)\,dt$. Then, $\phi$ is smooth, $\phi'=\tilde{\psi}$, $\phi(a)=0$, and $\phi(b)=0$ (because we ensured that $\tilde{\psi}$ had zero average). Hence,
\begin{align}
0&=\int_a^bh(t)\phi'(t)\,dt\\
&=\int_a^bh(t)\tilde{\psi}(t)\,dt \\
&=\int_a^bh(t)\psi(t)\,dt - \left(\int_a^bh(t)\,dt\right)\cdot \left(\frac{1}{b-a}\int_a^b\psi(t)\,dt\right)\\
&=\int_a^bh(t)\psi(t)\,dt-0.
\end{align}
In other words, for all smooth functions $\psi$ on $[a,b]$ we have $\int_a^bh\psi=0$, and thus $h=0$ a.e. (hopefully you've already seen this result).
Best Answer
Suppose that $A \subset (0,1)$ is measurable, is of positive measure and $f<0$ on $A$. The idea is that we want to construct a continuous function $g$ such that $$\int_0^1 fg\, dx<0. $$ A logical way to do this would be to choose $g$ such that $g\geqslant 0$ in $A$ and $g=0$ on $(0,1) \setminus A$. However, since $A$ is only a measurable set, in general $g$ will be discontinuous.
The way to get around this is to use the result I mentioned in the comments. A direct corollary of this result is that, given $\varepsilon >0$, there exists a (relatively) closed set $F \subset A$ such that $\vert A \setminus F \vert <\epsilon$. Choosing $\epsilon = \vert A \vert /2 >0$, we have that $$\vert F \vert=\vert A \vert - \vert A \setminus F\vert= \vert A \vert /2 >0.$$ Since $\vert F \vert >0$, the interior of $F$ is nonempty. Thus, there exists an open set $U$ compactly contained in the interior of $ F$ (just take a small ball for example). Define $g$ such that $g$ is continuous, nonnegative, $g=0$ in $A\setminus F$, and $g=1$ in $U$. Then \begin{align*} \int_0^1 fg \, dx &=\int_F fg \, dx \\ &=\int_U f \, dx + \int_{F\setminus U} fg \, dx \\ &\leqslant \int_U f \, dx \\&<0. \end{align*} This completes the proof.