In your Moodle course click Participants and then from the drop-down menu choose Enrolment methods.
From the drop-down menu select Guest Access.
It is possible to add a password for the Guest access, but it is not necessary. Click Add method and the guest access is ready to use.
Teacher can give the course address as a link which takes to the Moodle login page and the user chooses Log in as a guest.