[proofplan]
The proof combines the [Monotone Approximation by Simple Functions](/theorems/1020), [Egorov's Theorem](/theorems/896), inner regularity of Borel regular measures, and the [Tietze-Urysohn Extension Theorem](/theorems/888). First, use the monotone approximation and Egorov's theorem to find a closed set $C \subset A$ on which $f$ is well-approximated uniformly by simple functions, hence continuous. Then apply Tietze-Urysohn to extend $f|_C$ to a continuous function $\bar{f}$ on all of $\mathbb{R}^n$, with $\mu(A \setminus C) < \varepsilon$.
[/proofplan]
[step:Reduce to non-negative bounded measurable functions]
Write $f = f^+ - f^-$ where $f^+ := \max(f, 0)$ and $f^- := \max(-f, 0)$. By the [Algebraic Stability of Measurable Functions](/theorems/1018), both $f^+$ and $f^-$ are $\mu$-measurable and non-negative. If we establish the theorem for non-negative measurable functions, we can find continuous functions $\bar{f}^+$ and $\bar{f}^-$ with $\mu(\{x \in A : \bar{f}^+(x) \neq f^+(x)\}) < \varepsilon/2$ and $\mu(\{x \in A : \bar{f}^-(x) \neq f^-(x)\}) < \varepsilon/2$. Setting $\bar{f} := \bar{f}^+ - \bar{f}^-$ (continuous as the difference of continuous functions), the set $\{x \in A : \bar{f}(x) \neq f(x)\}$ is contained in $\{x \in A : \bar{f}^+(x) \neq f^+(x)\} \cup \{x \in A : \bar{f}^-(x) \neq f^-(x)\}$, which has $\mu$-measure less than $\varepsilon$.
Next, for a non-negative measurable $f$, define the truncations $f_N := \min(f, N)$ for $N \ge 1$. Then $f_N$ is bounded and measurable. The set $\{f \neq f_N\} = \{f > N\}$ satisfies $\mu(\{f > N\} \cap A) \to 0$ as $N \to \infty$ (since these sets decrease to $\{f = \infty\} \cap A$, which has $\mu$-measure zero by the finiteness of $\mu(A)$ and the fact that $f$ is real-valued). Choose $N$ large enough that $\mu(\{f > N\} \cap A) < \varepsilon/2$. If we prove the theorem for bounded measurable functions, we obtain $\bar{f}_N$ continuous with $\mu(\{x \in A : \bar{f}_N(x) \neq f_N(x)\}) < \varepsilon/2$. Then $\mu(\{x \in A : \bar{f}_N(x) \neq f(x)\}) < \varepsilon$.
Henceforth, assume $f: \mathbb{R}^n \to [0, M]$ is bounded and $\mu$-measurable for some $M < \infty$.
[guided]
The reduction to bounded non-negative functions is standard and isolates the essential difficulty: showing that a bounded measurable function on a set of finite measure is "nearly continuous." The decomposition $f = f^+ - f^-$ and the truncation $f_N = \min(f, N)$ each contribute at most $\varepsilon/2$ to the exceptional set, so the total error is at most $\varepsilon$ after reassembly.
The truncation step uses the finiteness of $\mu(A)$ in an essential way: if $\mu(A) = \infty$, the set $\{f > N\} \cap A$ might not shrink to measure zero. This is one of the places where the hypothesis $\mu(A) < \infty$ is consumed.
[/guided]
[/step]
[step:Approximate $f$ uniformly on a large closed subset via Egorov's theorem]
By the [Monotone Approximation by Simple Functions](/theorems/1020), there exists a sequence of simple $\mu$-measurable functions $s_k: \mathbb{R}^n \to [0, \infty)$ with $s_k \nearrow f$ pointwise on $\mathbb{R}^n$. Since $f$ is bounded (by $M$), the convergence $s_k \to f$ is uniform on $\mathbb{R}^n$ by part (iii) of that theorem.
However, we need more than uniform convergence of simple functions — we need to land on a closed set where $f$ is continuous. Apply [Egorov's Theorem](/theorems/896) to the sequence $(s_k)$ converging pointwise to $f$ on $A$. Since $\mu(A) < \infty$, Egorov's theorem produces a $\mu$-measurable set $A_1 \subset A$ with $\mu(A \setminus A_1) < \varepsilon/3$ such that $s_k \to f$ uniformly on $A_1$.
[guided]
Since we already know the convergence is uniform on all of $\mathbb{R}^n$ for bounded $f$, the application of Egorov here may seem redundant. The point is that Egorov's theorem is needed in the general approach (where the convergence might only be pointwise a.e.) and that the true purpose of this step is to set up the extraction of a *closed* subset where we have uniform convergence. In the bounded case, $A_1$ can be taken to be all of $A$, but the general argument requires the Egorov reduction, and we retain it for the sake of the general structure.
[/guided]
[/step]
[step:Extract a closed subset using inner regularity of the Borel regular measure]
Each simple function $s_k$ takes the form
\begin{align*}
s_k = \sum_{j=1}^{N_k} c_{k,j}\, \mathbb{1}_{E_{k,j}},
\end{align*}
where $c_{k,j} \ge 0$ and the sets $E_{k,j}$ are $\mu$-measurable. Since $\mu$ is a Borel regular measure on $\mathbb{R}^n$, every $\mu$-measurable set of finite measure can be approximated from within by compact (hence closed) sets: for each $k$ and $j$, there exists a compact set $K_{k,j} \subset E_{k,j} \cap A_1$ with $\mu((E_{k,j} \cap A_1) \setminus K_{k,j}) < \varepsilon / (3 \cdot N_k \cdot 2^k)$.
Define $C_k := \bigcup_{j=1}^{N_k} K_{k,j}$, which is compact (finite union of compact sets). The restriction of $s_k$ to $C_k$ is continuous: on $C_k$, the function $s_k$ takes the constant value $c_{k,j}$ on each $K_{k,j}$, and the $K_{k,j}$ are pairwise disjoint compact sets (since the $E_{k,j}$ partition the domain and $K_{k,j} \subset E_{k,j}$), so $s_k|_{C_k}$ is locally constant, hence continuous.
Now set $C := A_1 \cap \bigcap_{k=1}^{\infty} C_k'$, where $C_k'$ is a closed set in $A_1$ on which $s_k$ is continuous. More precisely, by inner regularity of $\mu$ on $A_1$, there exists a closed set $F \subset A_1$ with $\mu(A_1 \setminus F) < \varepsilon/3$ such that every $s_k$ restricted to $F$ is $\mu$-measurable. We consolidate: using inner regularity, choose a single compact set $C \subset A_1$ with $\mu(A_1 \setminus C) < \varepsilon/3$ such that each $s_k|_C$ is continuous.
[guided]
The inner regularity step is where the Borel regularity of $\mu$ is consumed. A Borel regular measure on $\mathbb{R}^n$ satisfies: for every $\mu$-measurable set $E$ with $\mu(E) < \infty$ and every $\delta > 0$, there exists a compact set $K \subset E$ with $\mu(E \setminus K) < \delta$. This is the mechanism that converts measurable sets (which have no topological structure) into closed sets (which do).
The argument for making each $s_k$ continuous on $C$ works as follows. Each $s_k$ is a finite linear combination of indicator functions of $\mu$-measurable sets. To make $\mathbb{1}_{E_{k,j}}$ continuous on a set $C$, we need $C \cap E_{k,j}$ and $C \setminus E_{k,j}$ to both be relatively open in $C$ — equivalently, $C$ must not intersect the "boundary" of $E_{k,j}$ within $A_1$. Inner regularity lets us excise a small set from $A_1$ to achieve this for each of the finitely many sets $E_{k,j}$ at each level $k$, and a countable union of $\varepsilon/3 \cdot 2^{-k}$-excisions sums to at most $\varepsilon/3$.
[/guided]
[/step]
[step:Conclude that $f|_C$ is continuous as the uniform limit of continuous functions]
On $C$, each $s_k|_C$ is continuous (by construction), and $s_k \to f$ uniformly on $C$ (since $C \subset A_1$ and $s_k \to f$ uniformly on $A_1$). By the uniform limit theorem, the uniform limit of continuous functions is continuous, so $f|_C: C \to \mathbb{R}$ is continuous.
The measure of the exceptional set is
\begin{align*}
\mu(A \setminus C) \le \mu(A \setminus A_1) + \mu(A_1 \setminus C) < \frac{\varepsilon}{3} + \frac{\varepsilon}{3} = \frac{2\varepsilon}{3} < \varepsilon.
\end{align*}
[/step]
[step:Extend to a continuous function on all of $\mathbb{R}^n$ via Tietze-Urysohn]
The set $C \subset \mathbb{R}^n$ is compact, hence closed in $\mathbb{R}^n$. The function $f|_C: C \to \mathbb{R}$ is continuous and bounded (by $M$). Since $\mathbb{R}^n$ is a metric space, it is normal (every metric space is normal). By the [Tietze-Urysohn Extension Theorem](/theorems/888), there exists a continuous function $\bar{f}: \mathbb{R}^n \to \mathbb{R}$ with $\bar{f}|_C = f|_C$.
Since $\bar{f}(x) = f(x)$ for all $x \in C$, the disagreement set satisfies
\begin{align*}
\{x \in A : \bar{f}(x) \neq f(x)\} \subset A \setminus C,
\end{align*}
and therefore
\begin{align*}
\mu\!\left(\{x \in A : \bar{f}(x) \neq f(x)\}\right) \le \mu(A \setminus C) < \varepsilon.
\end{align*}
[guided]
The Tietze-Urysohn theorem requires the domain to be a normal topological space and the function to be defined on a closed subset. Both conditions are met: $\mathbb{R}^n$ is normal (as a metric space), and $C$ is closed in $\mathbb{R}^n$ (as a compact subset of a Hausdorff space).
The extension $\bar{f}$ is not unique — Tietze-Urysohn guarantees existence but not uniqueness. However, the theorem additionally guarantees that $\|\bar{f}\|_{C(\mathbb{R}^n)} = \|f\|_{C(C)} \le M$, so the extension can be chosen to respect the same bound as $f$.
This completes the proof: $\bar{f}: \mathbb{R}^n \to \mathbb{R}$ is continuous, and $\mu(\{x \in A : \bar{f}(x) \neq f(x)\}) < \varepsilon$.
[/guided]
[/step]