To keep it brief: the realized variance estimator, $RV_t$, is only a consistent estimator of Quadratic Variation (QV) under absence of microstructure noise.
Following the paper of Barndorff‐Nielsen, O. E., & Shephard, N. (2002) they show how the realized variance estimator,
$$
RV_t = \sum_{i=1}^n r_{i,t}^2,
$$
is a consistent estimator of QV under absence of microstructure noise, when the number of intraday observations goes to infinity:
$$
RV_t = \lim_{n \rightarrow \infty} \sum_{i=1}^n r_{i,t}^2 \overset{\mathbb{P}}{\longrightarrow} QV_t.
$$
In their setup they model the log-price process following a diffusion on the form:
$$
dp_t = (\mu + \beta \sigma^2_t) \: dt + \sigma_t dW_t,
$$
where $\mu$ is the drift and $\beta$ is the risk-premium. Following from the diffusion setup of the log-price process, the quadratic variation $QV_t$ of the log-returns can be described as:
$$
QV_t = \int_{t-1}^t \sigma^2_s \: ds,
$$
which is equivalent to the integrated volatility/variance $IV_t = \int_{t-1}^t \sigma^2_s \: ds$ (only under a diffusion process, see paper).
I have highlighted some key findings from the above paper:
$RV_t$ is also an unbiased estimator when $\mu = \beta = 0$.
In practice, the effect of $\mu$ and $\beta$ on realized volatility/variance, is extremely small and is often safe to ignore in many cases (See section 5 of above paper).
Under the diffusion setting, when $\mu = \beta = 0$, and assuming absence of noise, $RV_t$ is a consistent estimator of Integrated variance/volatility $IV_t$:
$$
\lim_{n \rightarrow \infty}RV_t \overset{\mathbb{P}}{\longrightarrow} QV_t = \int_{t-1}^t \sigma^2_s \: ds.
$$
Avoiding microstructure noise can be done by sparse-sampling intraday observations.
As a last note Zhang, L., Mykland, P. A., & Aït-Sahalia, Y. (2005) show that when microstructure noise is present, the bias of the $RV_t$ grows with $n$ and thus explodes when $n \rightarrow \infty$. Thus the realized volatility estimates not the true integrated volatility/variance, but rather a noise contaminated counterpart.