If you marry a close relative (1st cousin or closer) there is a chance of your children gaining the inbred trait. My question is simple, as I accidentally ended up in a similar situation; My half brother Alfonso is king of France, and I am emperor of Hispania and married to his daughter and in line to inherit the HRE (the Salians somehow managed to shift succession law to agnatic-cognatic primogeniture and have ruled the HRE for 250 years and have very strong dynasty members). Anyway, my heir is inbred, weak, insane, and an imbecile, and for some reasons my assassins have failed to kill him. I am 65 and not getting any younger. I used the console, and it turns out the child is not actually mine anyway. He is the son of my wife and some random courtier descended from the Jimenas (I am the great great great grandson of El Cid) which raises this question; does the game use actual father or perceived father to determine wheather the child is "inbred"? I have triple checked, and the Jimena boy is not related in any way to me for five generations.
The game uses the actual father to determine genetic traits, including Inbred. It seems your wife is somehow blood-related to her boy toy. Keep in mind that this blood relation might also be through a child resulting from an affair, so you won't see it in the "official" family tree or dynasty tree.
Inbred also comes with a hefty health penalty. Inbred people rarely survive until adulthood. Weak also has a health penalty. So it is very likely that the problem will solve itself.
When you want to make sure that he does not inherit, refer to the question "How do I prevent my imbecile son from being an heir?". Should you still end up having to play as that abnormity, refer to "What methods of suicide cause the least amounts of collateral damage?" for how to quickly forward the crown to the next eldest brother.