Definition of energy of a signal

I was wondering why the energy of a signal is defined as

$$E=\int_{-\infty}^{\infty}|x(t)|^2dt$$

I mean, I know that it is a definition, but is there a physical reason for it being defined like that?

As we know $E = Pt$ where $E$ is the energy and $t$ is the time. In the continuous domain $t$ is never ending and its beginning isn't known either.

Now, signals in the continuous domain are voltages and as you know from Ohm's Law $V = IR$ and $P = I^2R$.

This basically tells you that for a given resistance $R$, the energy of a signal over a time interval is given by the integration of the power. So,

$$E = \int\limits_{t_1}^{t_2} P(t) ~dt$$

which in this case becomes

\begin{align} E &= \int\limits_{-\infty}^{\infty} I^2(t)R ~dt\\ &= R\int\limits_{-\infty}^{\infty} I^2(t) ~dt\\ &= \int\limits_{-\infty}^{\infty} I^2(t) ~dt~~\text{(For $R = 1$)} \end{align}

Usually in SP world we like to represent the signal as $x(t)$ giving us

$$E = \int\limits_{-\infty}^{\infty} \left|x(t)\right|^2 ~dt$$

Hope this helps!