Well, first of all you should try to do this on your local site or staging site or a develop environment. However, there may be scenarios when you want to test a theme or plugin on production site directly.
WordPress Health Check plugin allows doing the same. The plugin’s troubleshooting mode is very smart. While you are in troubleshooting mode, if you activate any theme or plugin it is effective only for the logged in admin.
Thus, your visitors are not affected at all. Below video gives a quick overview how you can test a theme on a site using Health Check & Troubleshooting plugin.