I suspect that you used wordpad or some other editor to modify cgi.cfg. Doing so, adds weird characters to files, that you can’t see.
Edit your cfg files with vi ONLY, or some other approved editor.
So fix that line using vi. Delete the entire line and add the same text you pasted above.
main_config_file=/usr/local/nagios/etc/nagios.cfg