It depends on the topology of $E$. Here is a simple example showing $f$ might not be Borel.
By definition, a function is Borel-measurable if the preimage of every open set is Borel. However, it can be shown that it suffices to show the the preimage of every half ray $[-\infty, a )$ is Borel.
Now the exampple. Set $E = \{0,1,2\}$ where the probability (measure) of each point is $1/3$. Now let $f(x)=x$. It is measurable since every subset of $E$ is measurable (this applies also to your definition).
Equip $E$ with the indiscrete topology. That is, $E$ and $\emptyset$ are the only open sets. This implies that the Borel $\sigma$-algebra is $\{\emptyset,E\}$.
Consider $f^{-1}([-\infty,2))=\{0,1\}$. It is the inverse image of a open set but $\{0,1\}$ is not a borel set of $E$. Hence $f$ is not a Borel-measurable function.
Lebesgue gave a characterization of all Borel functions in terms of pointwise convergence and continuity. But it requires a basic knowledge of the Borel hierarchy. Roughly speaking, functions that can be obtained :
(1) initially, as the pointwise limit of continous functions (call this class 1) and
(2) as the pointwise limit of functions of the previous class (there are called Baire classes).
have a tight relationship to each level of the Borel hierarchy. Their preimages lie at each level.
If you are interested in these topic, look at A. Kechris's book Classical Descriptive Set Theory, which is the traditional discipline where Borel sets are studied in depth.
Definition 1 gives measurability of $f$ with respect to the Borel-$\sigma$-algebra on $\mathbb{R}$, i.e. the $\sigma$-algebra generated by the open sets. In contrast, Definition 2 defines the measurability of
$$f: (X,\Sigma) \to (\mathbb{R},\Sigma'),$$
i.e. we do not necessarily consider the Borel-$\sigma$-algebra on $\mathbb{R}$, but an arbitrary $\sigma$-algebra on $\mathbb{R}$. If $\Sigma' = \mathcal{B}(\mathbb{R})$, then both definitions are equivalent. This follows from the fact that the family $\{(a,\infty); a \in \mathbb{R}\}$ is a generator of $\mathcal{B}(\mathbb{R})$.
Best Answer
It depends what $\sigma$ algebra you are considering on the target space.
When everyone talks about measureable functions on $\mathbb R$, they mean that $\mathcal O_Y$ is the the $\sigma$-algebra of Borel sets (generated by open intervals). This means that the preimage of an open interval like $(a,b)$ is measurable, but the preimage of a Lebesgue measurable set may not be measurable.