To have a reason; there is an explanation or (sometimes an excuse) for something. Used in phrases like 'there's a reason (for...)' or 'for a reason.'
彼が遅刻したのには訳がある。後で詳しく話すよ。
There's a reason he was late. I'll explain in detail later.
単純に諦めたわけではない。訳があってその決断をしたんだ。
It's not that I simply gave up. I made that decision for a reason.
そんなことを言う前に、まず相手に訳を聞いてみて。
Before saying that, first ask the other person for their reason.