Let us consider an ideal gas. Let it be present initially in a state $(p_1,v_1,t_1)$. Now let it be driven to another state $(p_2,v_2,t_2)$. Why is it so that during this process the maximum work can be obtained if the ideal gas is transformed from one state to another by a reversible process ?
A reversible process leaves entropy unchanged. Entropy never decreases and so an irreversible process involves an increase in entropy. Increases in entropy absorb work that would otherwise be spent on the environment.