$\textbf{Lemma:}$ Let $X$ and $Y$ be Banach spaces, and let $T \in \mathscr{B}(X, Y)$ such that $\operatorname{ran} T$ is closed. Then there exists a constant $M > 0$ such that for any $y \in \operatorname{ran} T$, there exists $x \in X$ with $y = Tx$ and $\|x\| \leq M\|y\|$.
$\textbf{Proof:}$ Only by the unique invertible operator $\hat{T} \in \mathscr{B}(X/\operatorname{ker} T, \operatorname{ran} T)$ such that $T = \hat{T} \circ \pi$.
$\textbf{Proof of the question:}$ Assume that $\operatorname{ran} T$ is both closed and of infinite dimension. Then there exists a constant $M > 0$ such that for any $y \in \operatorname{ran} T$, there exists $x \in X$ satisfying $y = Tx$ and $\|x\| \leq M\|y\|$. Since $\operatorname{ran} T$ is of infinite dimension, by Riesz's lemma, there exists a sequence of unit vectors $\{y_n\}_{n=1}^\infty \subseteq \operatorname{ran} T$ such that $\|y_i - y_j\| > \frac{1}{2}$ for $i \neq j$. Correspondingly, there is a sequence $\{x_n\}_{n=1}^\infty \subseteq X$ such that $y_n = Tx_n$ and $\|x_n\| \leq M\|y_n\| = M$. This implies that $\{y_n\}$ should have a convergent subsequence, leading to a contradiction.
$\textbf{Corollary1:}$ If $X$ and $Y$ are Banach spaces and $Y$ is of infinite dimension, and if $T \in \mathscr{B}_0(X,Y)$, then $\operatorname{ran} T \neq Y$.
$\textbf{Corollary2:}$ If there exist $A\in \mathscr{B}_0(X)$ such that $A$ is invertible, then $\operatorname{dim} X< \infty$.
We can also conclude it when $X=Y$ is a Hilbert space
$\textbf{Lemma:}$ If $\mathcal{H}$ is a Hilbert space and $K\in\mathscr{B}_0(\mathcal{H})$, then each closed subspace contained in $\operatorname{ran}K$ is finite-dimensional.
$\textbf{Proof:}$If $M$ is a closed subspace contained in $\operatorname{ran}K$, let $P_M$ be the projection onto $M$ and by the Douglas's lemma, there exist $A\in \mathscr{B}(\mathcal{H})$ on $\mathcal{H}$ such that $P_M=KA$, so $P_M$ is compact and therefore $M$ is of finite dimension.