Why does the second law of thermodynamics prevent 100% efficiency?
If you can convert all of the heat to work, you're reducing entropy by definition ($\Delta S = \frac{Q}{T}$ , If $Q<0$ then $\Delta S < 0$).
If you allow yourself to let some heat flow into somewhere cold (heating something up instead of using all of the heat to work) you raise the entropy in the cold substance enough to let you not defy the second law, and the rest can go to useful work.