In your Moodle course click Participants and then from the drop-down menu Enrolment methods.
From the Add method 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 to the Guest. After clicking the link the Guest has to use "Log in as a guest" on the Moodle login page.