It depends on the situation though. In most cases, a simple, “I’m sorry, we’re not able to make it” is sufficient.
When something is a big deal (like a wedding) and the person is either very close to you (like a sibling) or asking for a big favor (like for you or your kids to be in the wedding), I give the reason. In a case like that, a simple, “sorry, no” sounds more rude, because it implies that their event isn’t important to you. In that case, a short and loving, heart to heart is called for - in which I would briefly state why it is not possible for me to support the situation, and also state my respect and love for the person, and also state my hope that they will respect my need to follow my conscience. But that really is only reserved for big stuff.
There is, unfortunately, a middle ground. The fact is that there are times when the host will question your “sorry, no” even if it is a more casual affair. It’s not that uncommon for a person to follow up and ask for details about why you can’t go, and at some point, it might become silly to keep giving a vague reply. In that case, you can judge yourself whether a situation warrants an explanation (or an extrication from the conversation). The way I see it - if a person questions me repeatedly, maybe this is a sign that I am supposed to witness a little more directly. You can say things like, “to be honest, I am uncomfortable with ___ situation, so I thought it would be best if I didn’t attend.” Phrase it in terms of you being true to your conscience by not attending, and if that opens the door for a genuine discussion about your beliefs, great. If it opens the door to criticism of you or defensiveness, remind the person - “look, I didn’t set out to tell you what to do, or even what I believed. But you asked. I am happy to talk with you about my beliefs, and do understand that I am not judging you. Please respect my need to follow my own conscience, just as I am respecting your right to make your own decisions.”