What does the cog wheel in Ubuntu's Settings > Search do?

The cogwheel lets you customise the search locations (for Files).

enter image description here

But why doesn't this work on Ubuntu 18.04?

Because Ubuntu 18.04 doesn't have tracker pre-installed.

tracker is a metadata database, indexer and search tool for GNOME. It increases the speed of searching in the Files app and also supports full-text search. But this comes with a huge cost, it causes high CPU use and/or other performance issues.

That's why Ubuntu developers decided to ship Ubuntu 17.10 and 18.04 without tracker (see known issues).

If you manually install tracker and re-login, the cogwheel should be activated.