Solution (source code)

= Solution

For this model, the <Gauss-Markov theorem> states that $\widehat\beta$ is the unique minimum-variance <linear unbiased estimator> of $\beta$: if
$$
\widetilde\beta=\sum_{i=1}^n a_iY_i
$$
is unbiased for every $\beta$, then $\operatorname{var}(\widetilde\beta)\geq\operatorname{var}(\widehat\beta)$.

Indeed,
$$
\mathbb E\widetilde\beta
=\beta\sum_i a_ix_i,
$$
so unbiasedness is equivalent to $\sum_i a_ix_i=1$. Write
$$
a_i=\frac{x_i}{S_{xx}}+c_i.
$$
The constraint becomes $\sum_i c_ix_i=0$. Since the errors are <independent random variables>[independent] with common variance $\sigma^2$,
$$
\begin{aligned}
\operatorname{var}(\widetilde\beta)
&=\sigma^2\sum_i a_i^2\\
&=\sigma^2\left(\frac1{S_{xx}}+\frac2{S_{xx}}\sum_i c_ix_i+\sum_i c_i^2\right)\\
&=\frac{\sigma^2}{S_{xx}}+\sigma^2\sum_i c_i^2\\
&\geq\frac{\sigma^2}{S_{xx}}
=\operatorname{var}(\widehat\beta).
\end{aligned}
$$
Equality holds exactly when every $c_i=0$, which gives $a_i=x_i/S_{xx}$ and $\widetilde\beta=\widehat\beta$.