Why does moving the shorter line always work? Because the area is limited by the shorter height.
If you move the taller line, the width decreases and the height cannot increase (still limited by the shorter line). So area can only decrease or stay the same.
If you move the shorter line, width decreases but height might increase. This gives a chance for larger area. By always moving the shorter line, you explore all possible improvements.