To understand why we use the t-distribution, you need to know what is the underlying distribution of βˆ$\hat{\beta}$ and of the Residual sum of squares (RSS$RSS$) as these two put together will give you the t-distribution.

The easier part is the distribution of βˆ$\hat{\beta}$ which is a normal distribution - to see this note that βˆ$\hat{\beta}$=(XTX)−1XTY$({X}^{T}X{)}^{-1}{X}^{T}Y$ so it is a linear function of Y$Y$ where Y∼N(Xβ,σ2In)$Y\sim N(X\beta ,{\sigma}^{2}{I}_{n})$. As a result it is also normally distributed, βˆ∼N(β,σ2(XTX)−1)$\hat{\beta}\sim N(\beta ,{\sigma}^{2}({X}^{T}X{)}^{-1})$ - let me know if you need help deriving the distribution of βˆ$\hat{\beta}$.

Additionally, RSS∼σ2χ2n−p$RSS\sim {\sigma}^{2}{\chi}_{n-p}^{2}$, where n$n$ is the number of observations and p$p$ is the number of parameters used in your regression. The proof of this is a bit more involved, but also straightforward to derive (see proof here Why is RSS distributed chi square times n-p?).

Up until this point I have considered everything in matrix/vector notation, but let's for simplicity use βˆi${\hat{\beta}}_{i}$ and use its normal distribution which will give us:

βˆi−βiσ(XTX)−1ii−−−−−−−−√∼N(0,1)$$\frac{{\hat{\beta}}_{i}-{\beta}_{i}}{\sigma \sqrt{({X}^{T}X{)}_{ii}^{-1}}}\sim N(0,1)$$

Additionally, from the chi-squared distribution of RSS$RSS$ we have that:

(n−p)s2σ2∼χ2n−p$$\frac{(n-p){s}^{2}}{{\sigma}^{2}}\sim {\chi}_{n-p}^{2}$$

This was simply a rearrangement of the first chi-squared expression and is independent of the N(0,1)$N(0,1)$. Additionally, we define s2=RSSn−p${s}^{2}=\frac{RSS}{n-p}$, which is an unbiased estimator for σ2${\sigma}^{2}$. By the definition of the tn−p${t}_{n-p}$ definition that dividing a normal distribution by an independent chi-squared (over its degrees of freedom) gives you a t-distribution (for the proof see: A normal divided by the χ2(s)/s−−−−−−√$\sqrt{{\chi}^{2}(s)/s}$ gives you a t-distribution -- proof) you get that:

βˆi−βis(XTX)−1ii−−−−−−−−√∼tn−p$$\frac{{\hat{\beta}}_{i}-{\beta}_{i}}{s\sqrt{({X}^{T}X{)}_{ii}^{-1}}}\sim {t}_{n-p}$$

Where s(XTX)−1ii−−−−−−−−√=SE(βˆi)$s\sqrt{({X}^{T}X{)}_{ii}^{-1}}=SE({\hat{\beta}}_{i})$.

Let me know if it makes sense.