TheSilverDoe pointed out this condition doesn't make sense. $\mathbb{R} \setminus \{x\}$ is a dense set for any $x \in \mathbb{R}$. Let's consider what they suggested, $f(I)$ is contained in a set whose complement is dense.
By Proof of "the continuous image of a connected set is connected" we know that $f(I)$ is a connected set (as you noted). If $f(I) \subseteq T$, where $\mathbb{R} \setminus T$ is dense, then we know that $T$ must be a connected set. Let's try to think of a connected set which has a dense complement. A point satisfies this criteria, as we've noted above. What if there was more than one point, say $a,b \in T$, $a < b$? Then we know that, since $T$ is connected, $[a,b] \subseteq T$. But since $T^c$ is dense, we have that $T^c \cap [a,b] \neq \varnothing$, which is impossible since $[a,b] \subseteq T$. So it's impossible for there to be more than one element. We deduce from here that $f$ is constant.