Proof of a theorem on measurable functions
The collection of subsets of $S$ that have a preimage under $X$ in $\sigma$-algebra $\mathcal L$ can be shown to be a $\sigma$-algebra.
This is not really difficult to prove, since preimages are very coöperative in this.
So if this collection contains $\mathcal A$ as a subcollection then it will also contain $\mathcal B=\mathcal\sigma(\mathcal A)$ as a subcollection.
That means exactly that $X$ is measurable.
Let $\mathcal M = \{B\in \mathscr B : X^{-1}(B) \in \mathscr L\}$. You want to show that $\mathcal M$ is a monotone class and use the monotone class theorem, which states that if $M(\mathscr A)$is the smallest monotone class containing the algebra $\mathscr A$, then $M(\mathscr A) = \sigma(\mathscr A) = \mathscr B$. Now since by hypothesis $\mathcal M$ contains $\mathscr A$, and itself is a monotone class, then $\mathcal M$ contains $M(\mathscr A) = \mathscr B$. So $\mathcal M = \mathscr B$ which is exactly saying that $X$ is measurable.