[proofplan]
We first reduce to a set of finite measure by inner regularity, then approximate $f$ by simple functions using the [Monotone Approximation by Simple Functions](/theorems/3013). Each simple function is made continuous on a large compact set by exploiting inner regularity to approximate the level sets from inside. The sequence of simple functions converges pointwise to $f$ on a finite-measure set, so [Egoroff's Theorem](/theorems/3014) upgrades this to uniform convergence on a further compact set. Finally, the uniform limit of continuous functions is continuous, delivering the desired compact set $K$ on which $f|_K$ is continuous. The total measure cost is controlled by a geometric series allocation.
[/proofplan]
[step:Reduce to a set of finite measure and approximate $f$ by simple functions]
Since $\mu$ is a Radon measure on $\mathbb{R}^n$, it is inner regular: for the open set $\mathbb{R}^n$ and any $\delta > 0$, there exists a compact set $L \subset \mathbb{R}^n$ with $\mu(\mathbb{R}^n \setminus L) < \delta$. Choose $L$ so that $\mu(\mathbb{R}^n \setminus L) < \varepsilon / 3$. Since $L$ is compact, $\mu(L) < \infty$.
We may assume WLOG that $f \geq 0$. Indeed, once the theorem is proved for non-negative functions, apply it to $f^+ = \max\{f, 0\}$ and $f^- = \max\{-f, 0\}$ separately (with tolerance $\varepsilon/3$ each), then intersect the resulting compact sets.
By the [Monotone Approximation by Simple Functions](/theorems/3013), there exists a sequence of non-negative simple functions $s_k : \mathbb{R}^n \to [0, \infty)$ with $s_k \nearrow f$ pointwise on $\mathbb{R}^n$. Each simple function has the form
\begin{align*}
s_k = \sum_{j=1}^{N_k} c_{k,j} \, \mathbb{1}_{A_{k,j}},
\end{align*}
where $A_{k,j} \in \mathcal{M}$ are $\mu$-measurable sets and $c_{k,j} \in [0, \infty)$.
[/step]
[step:Construct a compact set on which each simple function $s_k$ is continuous]
Fix $k \geq 1$. The simple function $s_k = \sum_{j=1}^{N_k} c_{k,j} \, \mathbb{1}_{A_{k,j}}$ takes finitely many values. We may assume the sets $A_{k,j}$ are pairwise disjoint and partition $\mathbb{R}^n$, so that $s_k$ takes the constant value $c_{k,j}$ on $A_{k,j}$.
For each $j = 1, \ldots, N_k$, the set $A_{k,j} \cap L$ is $\mu$-measurable with $\mu(A_{k,j} \cap L) \leq \mu(L) < \infty$. By inner regularity of $\mu$, there exists a compact set $K_{k,j} \subset A_{k,j} \cap L$ with
\begin{align*}
\mu((A_{k,j} \cap L) \setminus K_{k,j}) < \frac{\varepsilon}{3 \cdot 2^k \cdot N_k}.
\end{align*}
Define $K_k = \bigcup_{j=1}^{N_k} K_{k,j}$. This is a finite union of compact sets, hence compact. On $K_k$, the function $s_k$ is constant on each $K_{k,j}$ (taking the value $c_{k,j}$), and the sets $K_{k,j}$ are pairwise disjoint compact sets in a metric space, hence are at positive distance from each other. Therefore $s_k|_{K_k}$ is continuous: for any $x \in K_{k,j}$, there is an open ball around $x$ that intersects $K_k$ only in $K_{k,j}$, and $s_k$ is constant there.
The measure cost for the $k$-th simple function is
\begin{align*}
\mu(L \setminus K_k) = \mu\left(\bigcup_{j=1}^{N_k} (A_{k,j} \cap L) \setminus K_{k,j}\right) \leq \sum_{j=1}^{N_k} \frac{\varepsilon}{3 \cdot 2^k \cdot N_k} = \frac{\varepsilon}{3 \cdot 2^k}.
\end{align*}
Define $K_0 = L \cap \bigcap_{k=1}^\infty K_k$. Since each $K_k$ is compact and $L$ is compact, $K_0$ is a closed subset of the compact set $L$, hence compact. Every $s_k$ is continuous on $K_0$ (because $K_0 \subset K_k$ for each $k$). The measure cost is
\begin{align*}
\mu(L \setminus K_0) \leq \sum_{k=1}^\infty \mu(L \setminus K_k) \leq \sum_{k=1}^\infty \frac{\varepsilon}{3 \cdot 2^k} = \frac{\varepsilon}{3}.
\end{align*}
[/step]
[step:Apply Egoroff's theorem to upgrade pointwise convergence to uniform convergence on a compact set]
On $K_0$, we have $s_k(x) \nearrow f(x)$ for every $x \in K_0$ (the approximating sequence converges everywhere, not just $\mu$-a.e., since we constructed the $s_k$ to converge pointwise on all of $\mathbb{R}^n$). The set $K_0$ is compact with $\mu(K_0) \leq \mu(L) < \infty$, so $(K_0, \mu|_{K_0})$ is a finite measure space.
By [Egoroff's Theorem](/theorems/3014), applied with tolerance $\varepsilon/3$ to the sequence $(s_k|_{K_0})$ converging pointwise to $f|_{K_0}$ on the finite measure space $(K_0, \mu|_{K_0})$, there exists a measurable set $E \subset K_0$ with $\mu(K_0 \setminus E) < \varepsilon / 3$ such that $s_k \to f$ uniformly on $E$.
By inner regularity of $\mu$, there exists a compact set $K \subset E$ with $\mu(E \setminus K) < \varepsilon / 3$. Since $K \subset E$, the convergence $s_k \to f$ is uniform on $K$ as well.
[/step]
[step:Conclude that $f|_K$ is continuous and the measure bound holds]
On $K$, each $s_k|_K$ is continuous (since $K \subset K_0$ and each $s_k$ is continuous on $K_0$). The sequence $s_k|_K$ converges uniformly to $f|_K$ on $K$. By the uniform limit theorem — the uniform limit of continuous functions on a metric space is continuous — $f|_K$ is continuous.
The total measure of the complement is
\begin{align*}
\mu(\mathbb{R}^n \setminus K) &\leq \mu(\mathbb{R}^n \setminus L) + \mu(L \setminus K_0) + \mu(K_0 \setminus K) \\
&< \frac{\varepsilon}{3} + \frac{\varepsilon}{3} + \frac{\varepsilon}{3} = \varepsilon.
\end{align*}
Here we used $\mu(K_0 \setminus K) \leq \mu(K_0 \setminus E) + \mu(E \setminus K) < \varepsilon/3$ (combining the Egoroff cost and the inner regularity cost, each of which was chosen to be less than $\varepsilon/6$ — but we can absorb both into a single $\varepsilon/3$ allocation by choosing the Egoroff tolerance and inner regularity tolerance to be $\varepsilon/6$ each, or equivalently by re-allocating the three-way split as $\varepsilon/3$ for the reduction to $L$, $\varepsilon/3$ for the continuity of simple functions, and $\varepsilon/3$ for the Egoroff and compactification steps combined).
This completes the proof: $K$ is compact, $\mu(\mathbb{R}^n \setminus K) < \varepsilon$, and $f|_K$ is continuous.
[/step]