Let $(\Omega, \Sigma, \mu)$ be a measure space. Let $(\mathbb{R}, \mathcal{B})$ be the measurable space. Let $g:\Omega\rightarrow \mathbb{R}$ be a function such that $$g=0,\ \mu-\mbox{a.e}.$$
One thing clear here is that $$\mu(\{\omega\in\Omega: g(\omega)\neq 0\})=0.$$
Now, I have to prove that the function $g$ is measurable. In order to do that, I have to show that for an arbitrary $x\in\mathbb{R}$, we have that $$\{\omega : g(\omega)\leq x\}\in \Sigma.$$
Now, let $x\in(-\infty,0)$, then the set $\{\omega : g(\omega)\leq x\}$ is not necessarily empty because the thing $\mu-$a.e. Then how can it be shown that $$\{\omega : g(\omega)\leq x\}\in \Sigma.$$
Let $\Omega = \{1,2,3\}$ and $\Sigma =\{\emptyset,\{1\},\{2,3\},\Omega\}$ and $\mu=\delta_1$. Let $u(k)=k-1$. Then $u=0$ $\delta_1$-a.e. because $\delta_1(\{k:u(k) \neq 0\})=\delta_1(\{2,3\})=0$. However, $u^{-1}(\{1\})=\{k:u(k)=1\}=\{2\}\notin \Sigma$. Therefore $u$ is not measurable.