I'm very unsure about what I did here, so if someone could proof check on the following, I would be very thankful.
Let $I$ be a an interval of $\mathbb{R}$.
For $f \in \mathcal{C}(I)$, we say that $P \in \mathcal{P}_n$ ($P$ is a polynomial of degree $n$) is the best approximation to $f$ if $\| f- P \|_{\infty} = \inf \, \{ \|f-P\|_{\infty} : P \in \mathcal{P}_n \} $.
I want to show that the best approximation of $f \in \mathcal{C}(I)$ by a constant is $\frac{1}{2}(\inf_{x \in I} f(x) + \sup_{x \in I} f(x))$.
$\text{Proof.}$
Since $f$ is continuous and $I$ is compact, $\inf f$ and $\sup f$ are reached and we have that $\inf f < \infty$ and $\sup f < \infty$.
Hence our claim is equivalent to saying that $\inf \, \{ \|f - c\|_{\infty}: c \in \mathbb{R}\} = \| f - \frac{1}{2}(\min f + \max f) \|_{\infty}$
Note that we have that $\inf_{c \in \mathbb{R}} \|f - c \|_{\infty} \leq \|f - \frac{1}{2}(\min f + \max f) \|_{\infty}$
Thus it suffices to show that for all $\varepsilon > 0$, there exists $c \in \mathbb{R}$ such that $\|f-c\|_{\infty} < \| f - \frac{1}{2}(\min f + \max f) \|_{\infty} + \varepsilon$
Let $\varepsilon > 0$. Define $c =: \frac{1}{2}(\min f + \max f - \varepsilon)$. We have that $$ \|f - c\|_{\infty} = \| f - \frac{1}{2}(\min f + \max f) + \frac{1}{2}(\min f + \max f) -c\|_{\infty} \leq$$ $$ \leq \| f - \frac{1}{2}(\min f + \max f)\|_{\infty} + \| \frac{1}{2}(\min f + \max f) -c \|_{\infty}= $$ $$ = \| f - \frac{1}{2}(\min f + \max f)\|_{\infty} + \frac{1}{2}\varepsilon <$$ $$ < \| f - \frac{1}{2}(\min f + \max f)\|_{\infty} + \varepsilon$$
Hint- By adding a constant to $f$, we may assume that $\min f=0$. By multiplying $f$ by a positive constant, we may assume that $\max f=1$. You correctly point out that $ \inf_c \|f-c\| \le \|f-1/2\|.$ The goal now is to prove that $$\inf_c \|f-c\| \ge \|f-1/2\|.$$ Let $c$ be arbitrary. Note that $\|f-c\| \ge |c|$ and $\|f-c\| \ge |1-c|$. Thus (why?) $\|f-c\|\ge \frac12$. So we are done if we can show $$ \|f-1/2\|=1/2.$$ Why is this true?