It's been in macOS for quite some time. Mostly dormant now but at one point it was what powered the Web Sharing option in the Sharing prefpane. It was also used in OS X Server (both the OS X versions designed for Xserve and the later "app" version) before that was largely whittled away.
I can't exactly find if it came with OS X since the beginning (which would predate nginx and friends), but it probably was a much more likely choice back in the day, and I guess that's why it's still included. Wouldn't be surprised to see it quietly disappear from later macOS releases, though.
"quite some time", is an understatement. The Apache HTTP Server was included as part of Mac OS X starting with version 10.0 (Cheetah), which was released on March 24, 2001. Prior to that, users of Mac OS X would have to manually install and configure Apache HTTP Server, if they desired to run a web server on their Mac.
I feel like it dates from earlier internet, before the age of walled garden takeover, when it still seemed like a decentralized internet would be the thing, and everyone would be, like, using a desktop GUI to create html or something. Of course everyone should have a webserver on their machine, right?
Apple was ahead of the curve on something that never arrived and many of us still miss.
The web sharing was more about sharing on local networks. It was the same concept as the Public folder for file sharing which dates back to NeXT. When Bonjour née Rendezvous was released Apple build an Apache module for it. When web sharing was enabled it would advertise the server over Bonjour. Safari still supports Bonjour server discovery IIRC.
The Apache install would obviously work over the Internet but sharing over the local network was its main purpose.
What kind of content do you think they imagined as use cases for local network http server over bonjour? Like for a small business? Or household? Or giving strangers access to something when you happened to be physically adjacent and on the same network?
It still seems like kind of evidence of a decentralized networking environment that never really came to be... bonjour in general kind of is, although it's still there and gets used for some specific things. But we have ended up doing a lot more connections "cloud-mediated" instead of peer-to-peer.
MacOS 9 had a personal web sharing feature. The Apache server with Rendezvous/Bonjour was basically the MacOS X implementation of the same. For OSX it was literally a free mechanism to add web sharing.
As for the use case, in the classic MacOS days and even early days of OSX the system didn't ship with support for Windows file sharing. It wasn't until IIRC Jaguar (10.2) that Samba shipped default with the system. Web sharing made for a workable lowest common denominator for getting content off a Mac to Windows. With Bonjour (in Safari) you'll see all the shares on the local network segment.
Additionally since web sharing was just Apache it shipped with a bunch of the extension modules. I believe PHP was enabled by default so you could just drop a PHP script in your Sites folder for a dynamic page. CGI was also simple to enable because thanks to all the shipped modules.
Bonjour is decidedly a local peer-to-peer discovery mechanism. Even the packets have a short TTL so they don't route beyond local segments. It's far too chatty to be a WAN discovery system.
We ended up with cloud mediated connections because of NAT and UPnP hole poking sucks. Residential routers are really shitty in general. They also don't make port forwarding easy (or possible). So a host behind a NAT router doesn't usually have good options for receiving incoming connections. That's why we've got a bunch of NAT traversal protocols and need public hosts to mediate those connections.
I can't exactly find if it came with OS X since the beginning (which would predate nginx and friends), but it probably was a much more likely choice back in the day, and I guess that's why it's still included. Wouldn't be surprised to see it quietly disappear from later macOS releases, though.