CGI was one of the first technologies where web servers could run server-side programs, it stands for "Common Gateway Interface" and was developed in the very early days of the WWW.
Basically, cgi defines a directory on the web server where the web server is allowed to run executables. The executables can be written in many different languages like perl, c, and others. usually the defined directory shows up as the /cgi directory in your web space, but the name is configurable.
Newer technologies like PHP, ASP, NET, JSP and such have become more popular than CGI for dynamic websites.