Let $S$ be the diagonal operator on $\ell^2(\mathbb{Z})$ given by $Se_n= S(n) e_n$ with $$S(n)=\begin{cases} \frac1{n^2}& n>0,\\ \frac1{|n|}& n<0,\\ 0&n=0. \end{cases}$$
Why $S$ has not a closed range?
Let $S$ be the diagonal operator on $\ell^2(\mathbb{Z})$ given by $Se_n= S(n) e_n$ with $$S(n)=\begin{cases} \frac1{n^2}& n>0,\\ \frac1{|n|}& n<0,\\ 0&n=0. \end{cases}$$
Why $S$ has not a closed range?
Copyright © 2021 JogjaFile Inc.
The most elementary way is what you did in the comments, namely noting that $e_n \in \mathcal{R}(S)$ for all $n \neq 0$, but
$$\langle e_0\rangle^{\perp} = \overline{\operatorname{span} \: \{ e_n : n \in \mathbb{Z}\setminus \{0\}\}} \not \subset \mathcal{R}(S)\,.$$
Another way is to note that $\ker S = \langle e_0\rangle$, and by the open mapping theorem, if $\mathcal{R}(S)$ were closed the restriction $T \colon (\ker S)^{\perp} \to \mathcal{R}(S)$ would have a bounded inverse. But the inverse is given by
$$T^{-1}(e_n) = \begin{cases} n^2 e_n &\text{if } n > 0, \\ \lvert n\rvert e_n &\text{if } n < 0. \end{cases}$$
This is not bounded.
Yet another way to phrase it is that if $\mathcal{R}(S)$ were closed, then - again by the open mapping theorem - there would be a $\delta > 0$ such that
$$S(U) \supset \{ y \in \mathcal{R}(S) : \lVert y\rVert < \delta\}\,,$$
where $U$ is the unit ball of $\ell^2(\mathbb{Z})$. But one easily verifies that
$$\frac{\delta}{2}e_n \notin S(U)$$
for all $n \in \mathbb{Z}$ with $\lvert n\rvert > \frac{2}{\delta}$.