By definition, a random variable is a function $X:\Omega \rightarrow \mathbb{R}$ with the property that $\{ \omega \in \Omega : X(\omega) \leq x \}$ for all $x$ in $\mathbb{R}$
When $X$ is a positive random variable and have a density , let the density be $f(x)$, we have :
$P(X>t) = \int^{+\infty}_{x=t} f(x)dx$
$\int_{t=0}^{\infty} \int^{+\infty}_{x=t} f(x)dx dt = \int_{x=0}^{\infty} \int^{t=x}_{t=0} f(x)dx dt = \int_{x=0}^{\infty} xf(x)dx = E[X] = \int_{t=0}^{\infty} P(X>t) dt = \int_{x=0}^{\infty} E[\mathbb{1}_{X>t}]dt $
which implies $X=\int_0^{\infty} \mathbb{1}_{X>t} dt$ , Which I could see in the case $X$ has a density,
But it is true in general even if X doesn't have a density, how come?
This is simply true for all positive real numbers.
$$X= \int_0^X 1 \mathrm dt = \int_0^{+ \infty} 1_{t<X} \mathrm dt$$