CAPM states that the expected return of any given asset should equal $ER_i=R_f+β_i (R_m-R_f)$, with α being the error term of the previous equation. Now, as α has an expected value of zero, then only way to achieve higher expected returns is taking on more β (given that $E[(R_m-R_f )]>0$). Every individual stock has some idiosyncratic risk in addition to its market β (true always when correlated less than perfectly with the market). Thus, we can get the best return/risk ratio by buying the market portfolio, as buying anything else, we could not get more expected return for the same β, but would only get some additional idiosyncratic risk.
Now, if you use historical data to estimate expected returns, you imply nonzero expected α-s for all assets. This is not coherent with the CAPM framework, so using this methodology within MPT, it has nothing to do with CAPM.
In effect by using MPT this way, you are generating a momentum based investment strategy, as you assume that assets that have had good returns historically will continue to have good returns in the future. Here is a paper in which a strategy is analyzed that utilizes short-term past historical returns as the expected returns for mean-variance optimization. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2606884
Edit: My initial answer was fairly ambiguous in terms of notation. To clarify my notion of the connection between CAPM, Jensen's Alpha and security characteristic line (SCL) in this context, as discussed in comments below:
We can define the SCL as $R_i = \alpha_i + \beta_i * R_m + \epsilon_i$ (with $R_i$ and $R_m$ being the realized security and market returns in excess of the risk-free rate and $\beta_i$ being the OLS regression beta with $R_i$ being the dependent variable and $R_m$ being the dependent variable).
We can define Jensen's alpha as $\alpha_i = R_i - \beta_i * R_m$ (with the variables defined as above). From here it can be seen that Jensen's alpha equation is just another form of the SCL (with $\alpha_i$ and $R_i$ switching sides, and the equation multiplied by $-1$).
When SCL and Jensen's alpha equations use realized returns, CAPM uses expected returns and can be formulated followingly: $E(R_i) = \beta_i * E(R_m) + \epsilon_i$ (notation similar to the previous equations, but with $E(R_i)$ being the expected excess return of the security and $E(R_m)$ being the expected return of the market portfolio), where $\epsilon_i$ is an error term , and $E(\epsilon_i) = 0$.
Now, when previous realized returns are used as proxies for the expected returns (i.e. $E(R_i) = R_i$ and $E(R_m) = R_m$), when plugged in to the CAPM, we find that it must be the case that $\alpha_i ≡ \epsilon_i$ for all $i$. As the (realized) $\alpha_i$ is a deterministic term and does not necessarily equal zero, we find that it can't be that $\alpha_i ≡ E(\epsilon_i) = 0$ for all $i$. Thus, using realized security returns as proxies for expected returns is not compatible with the CAPM.
Edit2: I figure I did not still actually answer your question very well. Sharpe’s development of the CAPM was originally spurred by the problem his graduate school supervisor Markowitz had with mean-variance optimization. As computers were slow and expensive, it was not feasible to do the calculations for a large number of securities.
Sharpe then first came up with the single-index model (SIM), which is basically what I previously referred to as the security characteristic line (SCL). The reasoning here was that the returns of different securities were related only through common relationships with some basic underlying factor. This being the case, instead of calculating all the pairwise covariances and the resulting portfolio volatilities the volatility of a (well diversified) portfolio (where all idiosyncratic risk is diversified away) could be approximated via securities’ weigthed covariances with the underlying factor (i.e. the market index). This decreased the computing power cost of the operation dramatically.
The SIM was thus used to decompose (“analyst’s”) estimates of expected returns on different securities for a more efficient calculation of the efficient frontier. CAPM followed soon after, when Sharpe concluded that (if alpha’s could not be predicted) the market portfolio itself is the tangency portfolio.
Now, as computing power is cheap today, and you can easily calculate the covariance matrix as well as the portfolio volatilies of a large number of different combinations, the SIM is no longer needed for the analysis.