Thermodynamically Reversible Processes: How does an infinitesimal step make a process reversible and how is maximum work derived from the process? My book says 'Maximum work can be obtained only from thermodynamically reversible processes,' but why is it so? What is the cause? 

Actually to me the definition of reversible process is confusing. It says that at each step during the process, equilibrium is maintained. But, let's say,we have to expand a gas in a cylinder headed by piston from pressure $P_i$ to $P_f$. Suppose,the process is done with innumerable infinitesimal steps. Then, say at each step, $dp$ is changed in the pressure. 

Before the step, gas and the piston were exerting same pressure $P_i$ . Now, when the piston is raised, gas does expand to equalize the pressure,which is $P_i - dp$ . So, at the end of the step, the gas &amp; the piston will exert same pressure $P_i - dp$ and hence will be in mechanical equilibrium. 

During the step,the gas and the piston was not in equilibrium;it was at the end of the step  the equilibrium is achieved. So, during each step of the process the gas would be at disequilibrium . So,will it really be a reversible process? It is contradictory with the definition. But it is true that during each step, the system is at disequilibrium though infinitesimally small by $dp$ . So, why does the definition tell that at each step,there is equilibrium?       

So, I have three questions: 


Why is maximum work only obtained from reversible processes? 
According to the definition, at each step of the reversible process,there must be equilibrium. But during each step, there is infinitesimal disequilibrium. So, why does the definition say so in-spite of the disequilibrium during each step? 
How do infinitesimal steps make a process reversible? I will be very grateful if anyone answer these three questions. 


Please help.
I'll give a mathematical answer, and an analogy also for ease of thought. These are my own intuitions, so they may work for you.

My mathematical reasoning: 

A lot of thermodynamic processes are phrased very carefully in terms of reversibility. Now my intuition of this is that reversibility is a consequence of the maths we must use.  Thermodynamics likes to look at continuous processes such that we can use integrals instead of summations in the calculations: this stands to reason since classical thermodynamics treats a collection of particles as moving, say, a piston continuously from one place to another, not in discrete steps.

Thus, one way to think about it is to think of reversibility as being necessary for an integral formulation. If we allow ourselves to try and think in infinitesimal steps, moving an infinitesimal step forward is just an infinitesimal away from going backwards and hence this is described as being reversible. In short, if a process really happens continuously then we must impose the condition of reversibility on it, otherwise the mathematics fails. 

My analogy:

Why this gives maximum work can be seen by analogy with a real life classical system: the tug-of-war. If you're in a tug of war with some of your friends who are of equal size to you and of equal strength, you're going to put in maximum work in pulling the rope. If one side is of unequal size and strength it becomes much easier for the stronger side. 

To be more serious, if your particles move your piston irreversibly (i.e. they never move backwards along the way) then no work has been expended in going backwards—only forwards. Reversible systems belie the work they've had to do since the physical outcome we actually see—the final outcome—shows the piston in the same place as the irreversible case, however what we haven't seen is the system battling backwards and forwards.

To conclude: if we imagine a set amount of work needs to be done to move a piston irreversibly from a point A to a point B, then the reversible case must provide maximum work since some of the time the system has battled going backwards and has still ended up in the same place as the irreversible case. 

EDIT: How to Achieve Equilibrium and still have Movement

I think the source of your confusion lies in the statement 'it was at the end of the step of the equilibrium'. I know what you mean by this, but I don't think it's precise. Equilibrium doesn't mean to describe position as such, but the oscillation of position. Even if you've physically pushed your piston a distance ds, it can still be in equilibrium by the very fact that it can still move forwards and backwards in its next spot. 

So in fact the periodicity of position is maintained at each step, which is what we mean by the equilibrium is maintained.

If we imagine a spring oscillating backwards and forwards, the movement of oscillation is what we mean here by a dynamic equilibrium. As long as this oscillation is maintained this equilibrium exists, however if we imagine our particles as springs, then the spring must be extended to reach its next spot. Hence in this sense we have equilibrium and movement can still occur.