Final answer:
When a gas expands and then is compressed, if the process is reversible, entropy stays constant, but in a real, irreversible process, the overall entropy of the system plus surroundings increases. Entropy is related to the unavailability of a system's energy to do work, so an increase in entropy results in less efficiency of energy conversion to work.
Step-by-step explanation:
When a gas undergoes an expansion, such as increasing its volume, there is a corresponding increase in entropy because the gas has more volume in which its particles can be dispersed, leading to a greater number of microstates and hence greater disorder. If you then attempt to compress the gas back to its original volume, the situation is different depending on whether the process is reversible or irreversible. In the reversible process, entropy can remain constant, and no excess entropy is transferred to the surroundings since the system returns to its initial state. However, in an irreversible process, the total entropy of the system plus surroundings will increase, meaning that you cannot restore the initial entropy of the system without an increase elsewhere in the universe.
According to the second law of thermodynamics, in any irreversible process, the entropy of an isolated system either stays constant (in a theoretically reversible process) or increases (in a real, irreversible process). Moreover, entropy is a measure of the unavailability of a system's energy to do work, so as entropy increases, less energy can be converted to work.