Here is the lagrangian of life:

$\textbf{Action} = \int_\text{Birth}^\text{Death} \textbf{(Benefits - Costs)dt}$

Stationary value of this integral gives you your life trajectory.