This strategy is used because normal compilation must account for all theoretical cases and as such is somewhat inefficient. At run-time, a dynamic compiler has more information about the task required and what data to process, and can therefore produce more efficient and less redundant code.
Java is a popular programming language featuring dynamic compilation (at least in the more advanced VMss).
The HP Dynamo project is an example of a transparent dynamic optimizer.
The emulator used in Mac OS to run 680x0 code on the PowerPC harware was a dynamically recompiling emulator.