Authentication secures Rails applications by checking if a user is logged in before allowing access to certain pages or actions. When a user sends a request, the app checks their login status. If the user is not logged in, they are redirected to the login page to enter their credentials. Once authenticated, the user can access protected content like their profile. This process prevents unauthorized users from seeing or changing sensitive information. The key variables tracked are whether the user is logged in and whether access is granted. The app only grants access when the user_logged_in variable is true, ensuring security.