The functions
$$
\varphi_{\lambda}(x)= \cos(\sqrt{\lambda}x),\;\;\;\psi_{\lambda}(x)=\cos(\sqrt{\lambda}(x-l))
$$
satisfy the differential equation $-f''+\lambda f = 0$ subject to the conditions
$$
\varphi_{\lambda}(0)=1,\;\varphi_{\lambda}'(0)=0,\;\;\;\;\;\;\psi_{\lambda}(l)=0,\;\psi_{\lambda}'(l)=0.
$$
These solutions are linearly independent except when the following Wronskian is $0$:
\begin{align}
W(\varphi_{\lambda},\psi_{\lambda})
& =\varphi_{\lambda}\psi_{\lambda}'-\varphi_{\lambda}'\psi_{\lambda} \\
& = \sqrt{\lambda}\{\cos(\sqrt{\lambda}x)\sin(\sqrt{\lambda}(x-l))
-\sin(\sqrt{\lambda}x)\cos(\sqrt{\lambda}(x-l))\} \\
& = \sqrt{\lambda}\sin(\sqrt{\lambda}(x-l-x))\\
& =-\sqrt{\lambda}\sin(\sqrt{\lambda}l)
\end{align}
The resolvent $R(\lambda)f=(-\Delta-\lambda I)^{-1}f$ is constructed for any $\lambda$ for which $W(\varphi_{\lambda},\psi_{\lambda})\ne 0$ as
$$
R(\lambda)f = -\frac{\psi_{\lambda}(x)}{W(\varphi_{\lambda},\psi_{\lambda})}
\int_{0}^{x}f(t)\varphi_{\lambda}(t)dt
-\frac{\varphi_{\lambda}(x)}{W(\varphi_{\lambda},\psi_{\lambda})}\int_{x}^{l}f(t)\psi_{\lambda}(t)dt.
$$
You can check that $R(\lambda)f$ satisfies the required conditions to be in the domain of $-\Delta$. In any event, you can verify that $-\Delta-\lambda I$ is invertible if $W(\varphi_{\lambda},\psi_{\lambda})\ne 0$, and that the inverse is the above operator. On other hand, you know that if $W(\varphi_{\lambda},\psi_{\lambda})=0$, then the operator is not invertible because $\varphi_{\lambda}$ is an eigenfunction for such $\lambda$. So that pins down the spectrum.