The reason why heat cannot flow from cold to warm is that the change in entropy will become negative, and that doesn't happen in a closed system. Negative entropy is by definition not possible. Here's why:
I think entropy gets a little more intuitive if we think of it in terms of statistical mechanics. If we imagine a box with a number of ideal gas particles, these particles can be arranged in many different ways. One way they can be arranged is withto have all the particles gathered in one corner of the box, and the rest of the box being empty. There are many different permutations of the individual particles which would all give this result - the state described as all the particles being in the upper left back corner is called a macrostate (describes the system macroscopically but doesn't care about which individual particle sits where), while each distinct "seating arrangement", or permutation, of the particles which all yield the same macrostate are called its microstates. We can easily observe the macrostate, while the microstate is much harder to observe.
It should be intuitively clear that there are many microstates which yield the same macrostate; but also that there are enormously many more microstates that yield the a macrostate in which the gas particles are more or less evenly distributed in the box. This is actually the statistical-mechanics definitiondefinition of entropy:
With $k_b$ being Boltzmannsthe Boltzmann constant and $\Omega$ being the number of possible microstates of the given macrostate. This also explains why we cannot have negative values of entropy: There is no such thing as "a negative number of microstates".
We then assume that the system starts in a low-entropy state and evolves through random fluctuations, or a random walk, in configuration space - that is, the "space" made up of all possible microstates (not confined to any particular marcostatemacrostate). You can imagine that each macrostate occupies a region in configuration space, the size of which is determined by the number of microstates it has - by its entropy. As the system evolves, once it has randomly walked out of its low-entropy initial configuration, it is it is veryvery unlikely that its random path will take it back there again that its random path will ever take it back there again, simply because it is so tiny compared to the immensely larger number of microstates of a high-entropy state. In fact, once the system has settled into its maximum entropy state, it is very unlikely that it will fluctuate out of this state again, due to simple statistics.
Now going back to the example of the original question, we can see the analog to the gas particle example, only instead of the geometrical position of the particles, the state is defined by the distribution of their kinetic energyenergies. Again, it is perfectly possible to have a configuration, in which all the kinetic energy is distributed over particles in the left side of the box, while all the particles on the right side are at rest. However, it should also be intuitively clear that there are immensely many more microstates in which the energy is evenly distributed over all the particles. So if our system starts in the low-entropy configuration in which one subsystem is hot and the other is cold, and is then allowed to evolve through random fluctuations through configuration space, again it will quickly leave the tiny "patch" of its initial macrostate and venture into regions of higher entropy - more microstates - from which it is very unlikely to ever return.
NOTE, though, that it actually is entirely possible for the system to randomly fluctuate back into a low-entropy stateit actually is entirely possible for the system to randomly fluctuate back into a low-entropy state - to have a negative change in entropy. It is possible to stir your cappuccino into a configuration that separates milk and coffee, or to suddenly gather all air particles in one corner of the room - it is just extremely unlikelyit is just extremely unlikely, and thus we never observe it in real life.