In any physics book I've read the Lagrangian is introuced as as a functional whose critical points govern the dynamics of the system. It is then usually shown that a finite collection of non-interacting particles has a Lagrangian $\frac{1}{2}(m_1\dot{x}_1^2 + \cdots + m_n \dot{x}_n^2)$. It is then generally argued that $L=T-U$. I feel like something is missing here.
I have been vague so let me try to be more precise in my question. Is the principle of least action an experimental hypothesis? Is it always true that $L=T-U$? When we don't know what the Lagrangian is, do we have to just guess and hope it is compatible with the dynamical equations we had already? Or can we perhaps start with the ansatz of a Lagrangian in some cases?