Many programs are for use other than interfacing with the user.
For example, you may need an independent program to be kicked off to do a bunch of calculations for you, and all you need is the end result. You don't need pretty boxes or buttons or bells and whistles. Just kick off the program and let it do its thing. Then when it's finished, maybe then you can have a GUI program take over and display the results. Depending on the situation, you may not care about the results, so even there you don't have a GUI program. But perhaps the rest of your application needs those results to operate, or to print reports, etc. etc.
There are thousands of examples. Your Mail Service that runs on your machine is command line. It never talks to a human, it just receives and delivers email. What does it need with GUI? The Web Service, same thing. A lot of the security programs are command line based, where they run in the background to verify that attempted access has the correct credentials. Etc. etc.
Very often you need to "filter" the output of a program, or "filter" the input before it gets to a program, or both at the same time. Commands like "grep", "sed", "awk", etc. are all command-line filters. For example, you could use "sed" to change every instance of the word "Ford" to the words "Henry Ford". Attempts to "GUI-fy" these tools have not been very successful.
Further, experts often prefer the command line tools. Someone will attempt to "GUI-fy" a tool so that noobs can use it, but then the GUI version will only work in the simplest cases. That's great for the noob, but the expert soon finds himself needing to go back to the more powerful command line version. And once you start using the powerful version for power uses, you soon find yourself using it for the simple cases also.
GUI is nice and all, but the command line isn't going away any time soon.