I was reading this link with the same question, but I couldn't quite understand what is happening. I will try to put my thoughts here.
Suppose $X$ is the random variable for a coin toss. Then $\Omega = \left\{1,2 \right\}$ and $\mathcal{F}=\left\{ \phi, \left\{1\right\}, \left\{2 \right\} , \Omega \right\}$.
If we define $X: \Omega \rightarrow \mathbb{R}$, we can recover the probabilities for all events in the event space $\mathcal{F}$.
However, if we define $X: \mathcal{F} \rightarrow \mathbb{R}$, then we would also have to map $\phi$ and $\Omega$ to $\mathbb{R}$. While for the first case we can simply assign these probabilities as $0$ and $1$, I don't understand why we can't do the same for this case.