Assume $g: \mathbb{R}^n \to \mathbb{R}$ is Lebesgue measurable, and assume that $\{x : g(x) \neq 0\}$ has positive Lebesgue measure.
Can $Mg$ ever be (Lebesgue) integrable?
EDIT: Let $f$ be a real-valued function on $\mathbb{R}^n$. We say $f$ is locally integrable if $\int_K |f(x)|\,dx$ is finite whenever $K$ is compact. If $f$ is locally integrable, define the maximal function of $f$ to be$$Mf(x) = \sup_{r > 0} {1\over{m(B(x, r))}} \int_{B(x, r)} |f(y)|\,dy.$$
If $g$ is locally integrable with $g\neq 0$ on a set of positive measure, then there is a constant $c>0$ and a ball $B$ such that $$ \int_B|g(y)|\;dy=c>0$$
Choose $R$ such that $B\subset \{y:|y|\leq R\}$, and suppose that $|x|>R$. If $r_0=2|x|$ then $B\subset B(x,r_0)$, hence $$ Mg(x)\geq \frac{1}{m(B(x,r_0))}\int_{B(x,r_0)}|g(y)|\;dy\geq \frac{1}{m(B(x,r_0))}\int_{B}|g(y)|\;dy $$ $$ =\frac{c}{m(B(x,r_0))}\geq \frac{C}{|x|^n} $$ for a constant $C$ depending on $g$ and $n$, but not $x$.
Therefore $Mg(x)\geq C|x|^{-n}$ for all sufficiently large $x$, so is not integrable on $\mathbb{R}^n$.