I think it must have been come through the PDF of a Gaussian distribution. Could somebody elaborate?
The reason behind it is the Hammersley–Clifford theorem. Basically, it gives you the conditions under which allows you the conditions under which the factorization is valid. Basically, you need $p(x) > 0$, and the exponential ensures it. Furthermore, it allows you to express very generally any sort of relationship between nodes.
The original idea stems from the doctoral thesis of Ising, where he introduced the now so-called Ising model, which you can see as a particular instance of a Markov Random Field (MRF). It describes a model consisting of several units whose dynamics is governed by pairwise interactions.
This idea has been generalized to MRFs and Conditional Random Fields. The nice thing about them is that you can look for the proper energy function for your model, and plug it in.