What you need really is a proper starter-course in thermodynamics, with a good textbook (and reader can guess which one I recommend!)
The logic goes as follows.
Various experiments (especially those due to Joule) imply that internal energy is a function of state (I'll explain this below), up to whatever precision the experiment achieved.
This leads one to propose that it is a universal law that there is a quantity, called energy, which is a function of state, for any given system. Such a law does not logically follow from (1). Rather, it is an intuition motivated by (1). Having proposed the law, one then reasons from it and one can deduce a large number of other things. These are then compared with experiment. The whole framework is found to be consistent with its own logic and with experimental results, so one has a good scientific model, and that is what science is all about.
Another way of stating the law, logically equivalent to (2), is to say that energy is conserved.
Now I will briefly expand on (1) and (2).
The starting-point is to define energy by observing that for some physical processes we know how to compute the quantity called energy. Here are some examples:
- gravitational potential energy $m g h$.
- elastic energy in a Hooke's law spring: $(1/2) k x^2$.
- electrical energy $\int I V dt$
- work done against pressure by a change in volume: $p\, \Delta V$
We first note that these are mutually consistent because of the observed inter-convertability of forms of energy in mechanics, a fact we refer to as conservation of energy.
Next we come to some macroscopic system such as a given mass of a fluid. We note that it has many different thermodynamic states, characterized by properties such as volume, temperature, pressure, density, salinity, and others. We arrange to keep all these properties fixed except two, say temperature and volume. Then we arrange to move the fluid around its state space without supplying or taking away any heat. This is done by providing thermal isolation to prevent heat flow, and then by providing or extracting energy in the form of work (quantified by one of the above formulae). It is found in such experiments that to go between any two given states, the amount of work which has to be done is the same, no matter what method is used or what sequence of intermediate states is followed (provided, as I said, there is no heat flow and the other variables such as mass are kept constant).
That is the fundamental observation here.
It can only be observed at an accuracy limited by the precision of the experiments.
But now we conjecture that it is indeed fully accurate. This conjecture is called the first law of thermodynamics. It then follows logically that we can define a quantity called $U$ in the following way. When the system state changes from $A$ to $B$ the quantity called $U$ changes by
$$
U_B - U_A = \mbox{amount of work required to move the state from A to B without heat exchange}
$$
The conjecture (called the first law of thermodynamics) guarantees that this definition will work.
We now have a quantity, associated with the symbol $U$, which can be associated with
each state of a system. The above can only be used to calculate differences in $U$ but this is ok. All we need to do is assign $U=0$ to some given state, and then the value of $U$ for all the other states can be obtained. We would also like to be able to consider processes involving heat exchange. This is done by defining a new quantity called heat, such that the heat exchange in a given process is given by
$$
Q = \Delta U - W
$$
where $W$ is the work done. This definition is not circular because we already defined all the quantities on the right hand side without the need to measure heat.
The quantity with the symbol $U$ now also earns a name. It is called internal energy.
So that is how internal energy is defined in thermodynamics without the need to mention anything about the microscopic structure of the entities involved.
Some final comments
How did we perform the 'magic' of getting a definition of internal energy without any idea of the microscopic structure or nature of energy? The answer is by the combination of theory and experiment. And that is, of course, how all of science is done. In this example the first step in the theoretical 'method' is simply to propose the laws of thermodynamics as axioms. This is similar to Newtonian mechanics where one may take Newton's laws as axioms. The next step is to learn how to reason from the axioms in useful ways.
I think that science education in the last fifty years has led some confusion about the logical basis of thermodynamics. It is widely said to require a microscopic model,
to which it is an approximation, valid in the thermodynamic limit. But in fact thermodynamics does not require any microscopic model. That doesn't make it either right or wrong; it is a useful generalization from experience, like every other scientific framework. The relationship between thermodynamics and microscopic models is that they should be mutually consistent in domains where their assumptions and methods both apply. If both are valid then they each provide a constraint on the other.