With the increasing number of applications on different operating systems, the developers found that there were a lot of code reuse and rewriting of the same logic over and over again to support certain functionalities in their programs. And because of that, the invention of code libraries came in handy:
Code libraries (.lib) include lots of functions to be copied to your program when required, so there is no need to reinvent the wheel and rewrite these functions again (for example, rewriting the code for the mathematical operations such as sin or cos for any application that deals with mathematical equations). This is done by a program called a linker, which basically copies the needed functions into a program and generates the executable file with all the needed functions inside. This process is called the static linking.