How should I ask a potential advisor why they haven't published in the last 3 years?
Instead of a question that might be insulting, you should probably ask them what they've been working on for the past few years. You need to know that in any case and their answer might give you the reason that they haven't got anything out recently. There may be a lot of work in progress but not yet ready. That sort of thing can actually be an advantage to you and knowing what it is, certainly is. 

But if their answer indicates not much research, then you might want to keep looking. 

By the way, this is a topic for a sit down conversation, not just an email. The latter might work, but would require more work from the prof and so you might not get as complete an answer.