**Why is the Lagrangian defined as L = T - U and the Hamiltonian defined as H = T + U, T is the kinetic energy and U is the potential energy? I think they didn’t randomly add or subtract them from each other. What are the observations lead them to establish these equations/operators?**

Historically, the Lagrangian formulation came first. The intellectual development of this formulation can be traced directly back to Newton’s Laws as a starting point and is in some sense just a vast generalization of \vec{F} = m\vec{a}. The Hamiltonian formulation came later. In this approach, the key conceptual leap was the desire to treat position and momentum variables on an equal footing. Driven by this particular desire, one can derive the Hamiltonian formulation directly from the Lagrangian formulation. A particularly lucid discussion of this topic aimed at an undergraduate audience is given by Malcom Longair’s book Theoretical Concepts in Physics.