Switching temporarily to another role
The switch roles feature allows a user to switch temporarily to another role from the user menu 'Switch role' so that they can see what the course would look like to someone with that role.
Switching roles is not perfect because you remain the same user, and your user may not have things like grades, which will make some student views look different than a real student might see. To get an 100% accurate view, the best thing to do is create a test student account and enrol it in your course. It is useful to have this logged-in on another browser so you can quickly switch back and forth.
Capability moodle/role:switchroles is required for the role so you can see role switch in the user menu.
Another way to see a student view is to "Log in as" one of your real students. You need the special capability user:loginas for this, and you do need to be careful that you don't accidentally change things for that student.
Site administration settings
The list of roles that you can switch to is set in the "Allow role switches" tab in 'Define roles' in the site administration.