There are two different views on thermodynamics, two approaches.
We can build thermodynamics as a phenomenological theory based on some postulates. According to this theory, heat will not flow from a cold body to a hot one. Never ever. And in this theory there is no concept of a microstate at all. But this theory is phenomenological and approximate.
But instead of starting with the postulates of thermodynamics, we can build thermodynamics based on statistical mechanics. This theory is more precise and fundamental than phenomenological thermodynamics. And this theory predicts that sometimes heat can flow from a cold body to a hot one. That is, the second law of thermodynamics holds only statistically, on average. (However, there is a formulation of the second law of thermodynamics, which, as far as we know, is absolutely accurate: it is impossible to build a perpetual motion machine of the second kind.)
When it comes to statistical thermodynamics, I don’t know of a perfect textbook. But for a basic level I would recommend the following two books:
- Kittel Thermal physics
- Huang Statistical mechanics
Theirs content partially overlaps, partially complements each other. Better to start with Kittel.