It is a tautology, i.e. a formula identically true (i.e. a formula $\mathcal A$ such that $\mathcal A \equiv T$), as you as verified using truth table method.
Thus, by Completeness Theorem for propositional logic it must be provable.
In many proof system in Hilbert-style (for propositional logic) it is an axiom.
We can prove it with Natural Deduction.
Proof :
i) $P$ - assumed
ii) $Q$ --- assumed
iii) $P,Q \vdash P$ --- from i) and ii)
iv) $P \vdash (Q \rightarrow P)$ --- from iii) by $\rightarrow$-I
v) $\vdash P \rightarrow (Q \rightarrow P)$ --- from iv) by $\rightarrow$-I.
For an explanation, see Jan von Plato, Elements of Logical Reasoning (2013), page 22 :
There is a limiting case of a derivation in which an assumption $A$ is made. It is at the same time a derivation of the conclusion $A$ from the assumption $A$, as in:
<ol>
<li><p>$A$ : hypothesis</p></li>
<li><p>$A \rightarrow A$ : 1,$\rightarrow$-I</p></li>
</ol>
<p>In terms of the derivability relation, the hypothesis on line 1 can be written as $A \vdash A$ and line 2 as $\vdash A \rightarrow A$.</p>
<p>Consider as another case $\vdash A \rightarrow (B \rightarrow A)$. Verbally, if we assume $A$, then $A$ follows under any other assumption $B$ :</p>
<ol>
<li><p>$A$ : hypothesis</p></li>
<li><p>$B \rightarrow A$ : 1,$\rightarrow$-I</p></li>
<li><p>$A \rightarrow (B \rightarrow A)$ : 1–2,$\rightarrow$-I</p></li>
</ol>
<p>This does not look particularly nice: We have closed an assumption $B$ that was not made. But if we say that an assumption was used $0$ times, the thing starts looking more reasonable. [...] we can say that assumption $B$ in the derivation of $A \rightarrow (B \rightarrow A)$ was used <em>vacuously</em>.</p>