Why are heat and work path functions but internal energy is a state function? I had found a statement given in my textbook which said that heat and work are path functions, but the sum of the two according to the first law is internal energy difference.
How is it that two path functions add up to give a state function?
 A: From a mathematical standpoint, given a function $f$ of two variables $x$ and $y$, then
$$\mathrm df =\alpha\, \mathrm dx +\beta\,\mathrm dy$$
where $\alpha\equiv \partial f/\partial x$ and $\beta\equiv \partial f/\partial y$. In general, neither $\alpha\,\mathrm dx$ nor $\beta\,\mathrm dy$ are the exact differentials, in which case they are so-called “path functions” while their sum is the differential of a “state function”.
Put differently, the differential of a generic state function is a linear combination of inexact differentials. In this case, the state function is the internal energy and the inexact differentials are identified as the infinitesimal work done by and heat added to the system.
A: Within Thermodynamics, it is not possible to answer this question. It is equivalent to asking why $\vec F = m \vec a$ in mechanics. The only explanation would be to assume an equivalent statement as a starting point, but then the problem would be why that statement is true. Even mathematical examples of non-exact differentials are misleading because they miss the physical key point. For most of the processes, there is no path in the thermodynamic space. Non-quasistatic transformations cannot be described in terms of the system's unique temperature and pressure.
There are two possible ways to answer.
The first is just a restatement of the experimental basis of any principle. Many direct and indirect experiments have shown the path dependence of heat and work and the possibility of introducing a path-independent quantity corresponding to their sum. In a way, this answer is equivalent to saying, "it is so because experiments tell us."
It is true, but there is a second possibility: recasting the question in terms of a theory that could encompass thermodynamics, providing a different point of view on the thermodynamic statements.
Indeed this is possible by exploiting the connection of macroscopic thermodynamic properties with the microscopic mechanics via Statistical Mechanics. Within such a there, the existence of a state function describing the internal energy is an almost trivial result of the conservative character of the atomic forces. Work and heat, depending on the details of the microscopic motions, are not, in general, state functions.
Macroscopic thermodynamics cannot use such an argument because there is no access to the microscopic degrees of freedom macroscopically. A different approach must be introduced to get an operative definition of internal energy. However, this is a sound argument from the conceptual point of view, providing a microscopic motivation for the macroscopic definition.
A: One way to define work and heat is as energy transfer on macroscopic and microscopic levels. There are many ways how one can repartition the same energy between macroscopic and microscopic degrees of freedom, that is many paths for changing the internal energy.
A: Suppose I have a very hot fluid (say, steam), which I divide into three portions.
I hook the first portion of my fluid up to a steam engine, and use it to (say) pump water out of a mine until my hot fluid reservoir cools to room temperature.
Then I run the same procedure, but disconnect the steam engine from the pump.  I'm not doing useful work anymore; all the work goes into overcoming friction in the engine, and (eventually) heating up the engine.
This suggests a third technique: don't even use the steam engine at all, just let the water cool to room temperature.
I have the same starting state and ending state in each scenario: boiling water and room temperature water (respectively).  Since I have the same state in each scenario, I might as well swap the portions before (or after) the procedures; I shouldn't be able to observe any difference.  So the internal energies must be the same, otherwise I should observe a difference after swapping.  This is why internal energy is a state function.
At the same time, the proportion of energy lost to heat (vs. work) depends dramatically on my machinery.  That's why those quantities are state functions.
(You might argue: OK, but how do we know that water doesn't "remember" what happened to it?  After all, maybe it has trace amounts of high-energy minerals in the water, at these are deposited inside the steam engine, but stay inside the fluid if I just let it cool.  Then the result of technique #3 has higher internal energy because it still contains the minerals.  But this posits a different end state for different processes, and so we should expect state functions like internal energy to differ.)
