Username and Password fields are not mandatory when adding a new student. (Required fields are in red).
If you do not fill the username and password, there is no way a student can login.
But in case you have to fill them because you create student accounts in Moodle, you can indeed use aleatory values.
If you do not communicate them to students, they will not be able to login either.
Finally, you can use the Students > Remove Access program to remove access to students. It works by adding a prefix to the Username: