Entropy is a measure of the disorder of a system and indicates whether a process is reversible.
The mathematically exact definition of the entropy change in a closed system is:
$$
\mathrm{d}S = \frac{\mathrm{d}Q}{T}
$$
This is the quotient of the heat supplied or removed, \(\mathrm{d}Q\), and the respective temperature \(T\).
Applying this definition to the isothermal processes in the Carnot cycle, we obtain for the isothermal expansion:
$$
\Delta S_1 = \frac{\Delta Q_1}{T_1} = R \ln \left(\frac{V_2}{V_1}\right)
$$
For the entropy of the isothermal compression, we obtain:
$$
\Delta S_2 = \frac{\Delta Q_2}{T_2} = -R \ln \left(\frac{V_2}{V_1}\right)
$$
Thus, the sum is:
$$
\Delta S = S_1 + S_2 = 0
$$
In general, the change in entropy for a reversible process is always 0.
As a counterexample, let us now consider two stones with equal masses and heat capacities but different temperatures.
If they are placed in contact with each other, heat flows from the hot stone to the cold one until an equilibrium temperature \(T_\mathrm{M}\) is reached.
Since the heat cannot flow back without external intervention, this process is irreversible.
Using \(\Delta Q = mc \Delta T\), the entropy change of the hot stone is:
$$
\Delta S_1 = \int_{T_1}^{T_\mathrm{M}} mc \frac{\mathrm{d}T}{T} = mc \ln\left(\frac{T_\mathrm{M}}{T_1}\right)
$$
Analogously, for the cold stone:
$$
\Delta S_2 = \int_{T_2}^{T_\mathrm{M}} mc \frac{\mathrm{d}T}{T} = mc \ln\left(\frac{T_\mathrm{M}}{T_2}\right)
$$
Thus, the total entropy change is, by applying logarithm rules:
$$
\Delta S = \Delta S_1 + \Delta S_2 = mc \ln\left(\frac{T_\mathrm{M}^2}{T_1 T_2}\right)
$$
The right-hand side of this equation must always be greater than 1 due to the definition of the equilibrium temperature.
Therefore, in general, \(\Delta S > 0\) for the change in entropy in an irreversible process.
In a closed system, entropy can therefore only remain constant or increase, but never decrease.
If we assume that the universe is a closed system and that most processes are irreversible, then one day a state will be reached in which entropy is maximal and no work can be performed.
This hypothetical point in time, which is still under discussion and lies far in the future, is called the heat death.