Why is a regression coefficient covariance/variance Title. I'd like to understand the intuition behind how regression coefficients are calculated, and why $$\frac{cov(x,y)}{var(x)}$$ gives a regression coefficient for dependent variable y and independent variable x? This feels like an elementary question but I have looked around the internet and can't anything answering this question specifically.

In simple linear regression we are dealing with the model
\begin{eqnarray*}
y_i = \beta_0 + \beta_1 x_i + \varepsilon_i, \quad \mbox{for} \quad i=1,\cdots,n.
\end{eqnarray*}
Let $\boldsymbol{y} = \left(y_1, \cdots, y_n\right)^{\prime}$, $\boldsymbol{x} = \left(x_1, \cdots, x_n\right)^{\prime}$, and $\boldsymbol{\beta} = \left(\beta_0, \beta_1\right)$.  Moreover, the design matrix is $\boldsymbol{X} = \left[\boldsymbol{1}_n, \boldsymbol{x} \right]$.  It may be shown that the MLE of $\boldsymbol{\beta}$ is
\begin{eqnarray*}
\widehat{\boldsymbol{\beta}} &=& \left(\boldsymbol{X}^{\prime}\boldsymbol{X}\right)^{-1} \boldsymbol{X}^{\prime} \boldsymbol{y} \\
&=& \frac{1}{n\sum_{i=1}^n x_i^2 - n^2 \bar{x}^2} \begin{pmatrix}
\sum_{i=1}^n x_i^2 & -n\bar{x} \\  
-n\bar{x} & n 
\end{pmatrix}
\begin{pmatrix}
n \bar{y} \\
\sum_{i=1}^n x_iy_i
\end{pmatrix}.
\end{eqnarray*}
Clearly, the second term, $\widehat{\beta}_1$, is given by
\begin{eqnarray*}
\widehat{\beta}_1 &=& \frac{n\sum_{i=1}^n x_iy_i - n^2 \bar{x}\bar{y}}{n\sum_{i=1}^n x_i^2 - n^2 \bar{x}^2} \\
&=& \frac{\frac{\sum_{i=1}^n x_iy_i - n \bar{x}\bar{y}}{n-1}}{\frac{\sum_{i=1}^n x_i^2 - n \bar{x}^2}{n-1}} \\
&=& \frac{cov(x,y)}{var(x)},
\end{eqnarray*}
where $var$ and $cov$ represent their sample counterparts.
