In one of my recent questions I got this answer: https://math.stackexchange.com/a/4348876/645867. In particular, it is said that "for an effective divisor $l(D)\leq \deg D +1$ and equality holds iff $D=0$ or $g=0$".
Where can I find a proof of this fact?
You can start considering the short exact sequence $0\to \mathcal{O_C(-D)}\to\mathcal{O_C}\to \mathcal{O_D}\to 0$ and then tensoring by $\mathcal{O(K_C)}$ since it is a free sheaf you get the short exact sequence,
$$0\to \mathcal{O_C(K_C-D)}\to\mathcal{O_C(K_C)}\to \mathcal{O_D(K_C)}\to 0, $$
Now, by taking cohomology we obtain that $0\to H^0(C,\mathcal{K_C-D})\to H^0(C,\mathcal{K_C})$ is exact, so $h^0(C,\mathcal{K_C-D})\leq h^0(C,\mathcal{K_C})=g(C). $
On the other hand, using Riemann-Roch theorem we know that $$l(D)\leq deg(D)+1-g+l(K_C-D),$$ but $-g+l(K_C-D)$ is positive, then $l(D)\leq deg(D)+1$.
If $l(D)=deg(D)+1$, then $l(K_C-D)=g$, which is true if $D=0$ by definition of genus or if $D\neq 0$, the genus $g$ must be zero by the last inequalities. The converse is clear, since $g=0$ implies that $C\cong \mathbb{P^1}$, and if $D=0$ it is trivial.