CGI was the late 90s equivalent of "function as a service". It was especially useful on multi-tenant web hosts, in a way that hasn't really been replicated since. The main advantage is absolute simplicity: you upload an executable, the webserver runs it under your uid/gid, it handles your request, and then it exits and doesn't consume any more resources.
The downside was the cost of starting an executable from scratch, which isn't that bad on Linux, plus the cost of whatever interpreter was handling the request if you didn't write it in C. Such as PHP or Perl ('use CGI' was very popular).
(what better solution would you choose in 2024 for a web server where you have 1,000 customers each of which has one or two CGI scripts that get on average one request every few minutes?)
The downside was the cost of starting an executable from scratch, which isn't that bad on Linux, plus the cost of whatever interpreter was handling the request if you didn't write it in C. Such as PHP or Perl ('use CGI' was very popular).
(what better solution would you choose in 2024 for a web server where you have 1,000 customers each of which has one or two CGI scripts that get on average one request every few minutes?)