WLOG $f$ is borel measurable, otherwise replace $f$ with a borel measurable function that equals $f$ almost everywhere. The hypotheses state that $\int f 1_A = 0$ for all intervals $A$. Note that these intervals form a $\pi$-system that generate the borel $\sigma$-algebra. Consider the set of functions for which $\int f g = 0$. It is clearly a vector space, contains the constant function $1$, and if $g_n$ increases to a bounded $g$, then by dominated convergence $\int f g_n \to \int fg$. It follows by the monotone class theorem that $\int f g = 0$ for all bounded borel measurable $g$. Take $g=f$ to conclude that $f=0$ a.e.