I will go for a mathematical answer. Hopefully, you will get something from it. Sorry if I will be a little bit synthetic.
Take the configuration space $M$ (with charts $q_u : U \to \mathbb{R}^n , U\subset M$) of your physical system, which we suppose is a differentiable manifold, and consider its cotangent bundle $T^*M$ (with charts $(q_u,p_u))$. Then you can define a natural 2-form $\omega := \sum_idq_i\wedge dp_i$ which turns out to be non-degenerate and closed.
Then you might think: since this $\omega$ emerges quite naturally, it would be nice if time evolution didn't change it. So you ask yourself: what kind of vector fields $v$ generate flows $\Phi_t^v$ that preserve $\omega$ (i.e. $\Phi_t^{v\ *}\ \omega = \omega\ \ \forall t$, with $^*$ meaning pull-back)?
The answer is given by $L_v\omega = 0$, with $L$ being the Lie derivative. Applying Cartan's magic formula for Lie derivatives of differential forms, you get the condition $0 = d(\iota_v\omega) + \iota_v(d\omega) = d(\iota_v \omega)$ since $\omega$ is closed.
Then, at least locally (depending on the topology of your system), this means that there is a function $H: T^*M \to \mathbb{R}$ such that $\iota_v\omega = dH$. This $H$ is what (in full generality) you can call Hamiltonian.
Since $\omega$ is non-degenerate, we can invert the relation and write $v = P(dH)$ (P is called "Poisson Tensor") and conclude that there is a natural flow ("Hamiltonian Flow") on the cotangent bundle of the configuration space associated to any function $H$. It so happens that if you are doing Newtonian mechanics and let $H$ be the energy, then the flow you get is the time evolution of the system. But the formalism is more general than that.