Why do we need $\sup$ and $\inf$ when we have $\max$ and $\min$. In my analysis text, it seems that $\max$ and $\min$ are replaced by $\sup$ and $\inf$ for 1D single variable function, why is this the case?

Well there isn't always a maximum.  Consider $S=\{r\in\Bbb Q:r<2\}$.  This is a bounded set with no maximum element.  But we can say that $2$ is the smallest number which is an upper bound of $S$.
