If the maximum exists, then the supremum and maximum are the same. However sometimes the maximum does not exist, and there is no maximal element. In this case it still makes sense to talk about a least upper bound.
The classic example is the set of all rationals whose square is less than or equal to $2$. That is the set $$A=\left\{ r\in\mathbb{Q}:\ r^{2}\leq2\right\}.$$
$A$ has no maximal element, however it does have a supremum and $\sup A=\sqrt{2}$.
An even simpler example is the set of all reals that are strictly less than $2$: $$B=\left\{ r\in\mathbb{R}:\ r<2\right\}.$$ This set has no maximum since for any $x\in B$ the element $\frac{x+2}{2}$ satisfies $x<\frac{x+2}{2}<2$. However it is not hard to see that $\sup B=2$.