In the derivation (image below) of getting the Fourier series coefficients, $e^{-jlw_0}t$ is integrated with $x(t)$ over a $[t_0,t_0+T]$ interval to isolate the $a_k$th coefficient.
But why the need to integrate at all? Why can't we replace the integration with just the difference of the product at the two endpoints $$ (x(t) e^{-jlw_0t}) \Big|_{t_0}^{t_0+T} = \sum_{k=-\infty}^\infty a_k e^{-jkw_0t} e^{-jlw_0t}\Big|_{t_0}^{t_0+T} $$
For $k\neq l$, $e^{jkw_0t} e^{-jlw_0t} \Big|_{t_0}^{t_0+T}= e^{j(k-l)w_0t} \Big|_{t_0}^{t_0+T}= 0 $ because it's a harmonic of $w_0$ and thus equal at $t_0$ and $t_0+T$
And for $k=l$, $e^{jkw_0t} e^{-jlw_0t} \Big|_{t_0}^{t_0+T} = 1$. So,
$\sum_{k=-\infty}^\infty a_k e^{-jkw_0t} e^{-jlw_0t}\Big|_{t_0}^{t_0+T} = a_l$
What am I missing here?

The purpose of a Fourier series is to approximate a function using sine waves. Because we want to capture the behaviour of the whole function across the given interval, we need to apply an operation that measures the function across that interval.
If we only measured the value of the function at the endpoints, then if we had two functions $f(t)$ and $g(t)$ such that $f(t_0) = g(t_0)$ and $f(t_0 + T) = g(t_0 + T)$ but were otherwise completely different, then we wouldn't be able to distinguish between them when we took the Fourier coefficients.