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?

They're different things.  Intuitively, supremum and infimum mean least upper bound and greatest lower bound, respectively, which are different concepts from maximum and minimum.  Thus, for example, $(-\infty, 0)$, the set of all negative reals, has a sup of $0$, but no maximum value: whatever negative value $x$ you come up with, $x/2$ is greater but still negative.
