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?

A maximum and a minimum are attained at some value of the variable (by definition), while the supremum and the infimum (least upper bound and greatest lowerbound) are values which can be approached as close as we wish, but are not necessarily attained.
Example: on $\mathbf R$, the function $\arctan$ has a $\sup$ and an $\inf\,$ ($\frac\pi2$ and $-\frac\pi2$), but there is no $x$ such that $\,\arctan x=\frac\pi2$.
