An Exercise About Best Approximation in Hilbert Space Suppose $H$ is a Hilbert Space. Let $M \subset H$  be a closed linear subspace that is not reduced to $\{0\}$, $f \in H, f \not \in M^{\perp}$, prove that there exists a unique $u \in M$ such that
\begin{equation*}
    u \in M, \|u\| = 1, (f,u) = \inf_{v \in M, \|v\| = 1}(f,v)
\end{equation*}
Is there a version in a Banach space without inner product structure (we can assume $f \in H^*$)
 A: First observe that $t(u) =(f,u)$ is continuous linear functional defined on $H.$ Then observe that $$\inf_{||v||=1 , v\in M} t(v) =\inf_{||v||\leq 1 , v\in M} t(v)  . $$
Then observe that $(M , (,))$ is with the scalar product induced from $H$ is again a Hilbert space and hence reflexive with the unit ball $B=\{x\in M: ||x||\leq 1\}.$
But in the reflexive spaces the unit ball is compact in the weak topology and every linear continuous functional on reflexive space is weak continuous. So since $t$ is continuous function on compact set $B$ there is an $u\in B$ such that $t(u) =\inf_{v\in B} t(v).$
But since $t$ is linear therefore must $||u||=1.$
A: There are counter-examples, that is, there are continuous linear functionals on Banach spaces such that the supremum in the definition of the norm of a functional is not attained.
For example, on the Banach space $c_0$, consider the linear functional
$$
f(x) = \sum_{i=1}^\infty 2^{-i}x_i.
$$
It is not hard to show that $\Vert f\Vert=1$, but there is no $x$ in $c_0$ such that $\Vert x\Vert=1$, and $|f(x)|=1$.  The missing $x$ wants to be $(1,1,1,\ldots)$ but of course it cannot.

The result you are looking for holds for reflexive Banach spaces (see MotylaNogaTomkaMazu's answer) and in fact, only
for reflexive spaces.  This is the content of James' Theorem  [1] which says that if every continuous linear functional on $E$
attains its norm, then $E$ is reflexive.
After James' Theorem appeared, the notion of subreflexivity was proposed to refer to Banach spaces such that the set of
norm-attaining linear functionals is dense in the dual.  However Bishop and Phelps [2] proved that every Banach space is
subreflexive so the term subreflexive fell from grace!
[1] James, Robert C., "Reflexivity and the supremum of linear functionals", Ann. of Math., 66  (1957),  159–169.
[2] Bishop, Errett and  Phelps, R. R.,  "A proof that every Banach space is subreflexive", Bulletin of the American
Mathematical Society, 67 (1961), 97–98.
