I'm reading the following theorem:

I don't understand what would go wrong if you would leave out the part that I marked green. I would think you could safely leave it out and replace the second to last sentence with this sentence:
"Then $f^{-1}(A)$ and $f^{-1}(B)$ are disjoint sets, whose union is $X$; they are open in $X$ because $f$ is continuous, and nonempty because $A\cup B=Z=f(X)$."
Or am I missing something ?
In this case, because of the very strong connection between the continuous function $f$ and the subspace $Z$ of $Y$ under consideration, your change would work, with a bit of extra argumentation.
Recall that the definition of disconnectedness of a subset $Z$ of a space $Y$ is:
Of course, this is equivalent to saying that $Z$ is disconnected (in the subspace topology).
You would now consider $f^{-1} [ U ]$ and $f^{-1} [ V ]$ and conclude that these are disjoint open subsets of $X$ whose union is $X$. That they are open follows from continuity of $f$. That their union is $X$ follows from the fact that $U \cup V \supseteq f [ X ]$. But to conclude that $\varnothing = f^{-1} [ U ] \cap f^{-1} [ V ] = f^{-1} [ U \cap V ]$ we have to make a bit of extra argumentation to conclude that this is empty (since it is not necessarily true that $U \cap V = \varnothing$. That extra bit is something to the effect of
A slight technicality that adds a bit of unnecessary complexity to the proof, in my opinion.