Measurability of a random variable $X$ is defined based on the inverse image.
Suppose $(\Omega, \mathcal{F}, P)$ is a probability space and $(\mathcal{X}, \mathcal{G})$ be a measurable space. Let $X$ be a random variable that is defined on this probability space by:
$$X: (\Omega,\mathcal{F}) \rightarrow (\mathcal{X}, \mathcal{G})$$
Then, $X$ is said to be $\mathcal{F}-$measurable if for all $E \in \mathcal{G}, X^{-1}(E) \in \mathcal{F}$. Every pullback in the image of $X$ should be in the $\sigma-$algebra $\mathcal{F}$.
For your example, $\mathcal{G} = \big\{\{3\}, \{5\}, \{3,5\}, \emptyset\big\}$.
I think you mean to define $\mathcal{F} := \big\{(-\infty, 0), [0,\infty), \emptyset, \mathbb{R}\big\}\;$ based on your equality condition in your definition of $X$. In this way, you can verify that the above holds.