Subtle is the Lord by Abraham Pais (1982) chapter 4 "Entropy and Probability" mentions well how Boltzmann first thought that the second law was an actual base physical law of the universe while he was calculating numerical stuff for it, including as late as 1872.
But then he saw an argument by Johann Joseph Loschmidt that given the time reversibility of classical mechanics, and because they were thinking of atoms as classical balls as in the kinetic theory of gases, then there always exist a valid physical state where entropy decreases, by just reversing the direction of time and all particle speeds.
So from this he understood that the second law can only be probabilistic, and not a fundamental law of physics, which he published clearly in 1877.
Considering e.g. Newton's laws of motion, you take a system that is a function of time , e.g. the position of many point particles, and then you reverse the speeds of all particles, then is a solution to that.
Articles by others on the same topic
The Second Law of Thermodynamics is a fundamental principle that governs the behavior of energy and entropy in physical systems. It can be stated in several ways, but one of the most common formulations is that in any energy transfer or transformation, the total entropy of an isolated system can never decrease over time. Instead, it will either increase or remain constant in reversible processes.