It seems that they are often interchangeable.
I think 理由 is used when there is a concrete evidence to provide the reason. Probably other people also could use the reason(理由） to explain it. On the other hand, わけ is used when you want to provide a reason with your interpretation. it's not so necessarily for other people use the reason（わけ） to explain it.
Background and Appendix:
For example, when you feel hungry and you want to eat donuts, you can say わけがあって、ドーナッツを食べる。(お腹が減って: your interpretation that you are hungry ）
If your stomach is empty, and that condition urges you to eat donuts （胃の中が空で: probably someone can observe that nothing in the stomach), you can say 理由があって、ドーナッツを食べる。
Or frogs suddenly began falling from the sky. You can say わけがわからない。since there is nothing seems to carry the frogs in the sky, so it's bizarre. However you might find the airplane in the sky, but it can be the reason but is not sufficient to explain the phenomena. You can say 理由がわからない since it's no clear evidence.
Yes, I agree with it's interchangeable in some situations as you know. It's not easy to provide the reason to explain the phenomena so long as I analyzed the difference.
理由 only refers to reason as opposed to result or consequence. It's always used in relation to a cause-and-effect relationship.
訳【わけ】 has much broader sense than 理由. Etymologically, わけ and 分かる【わかる】 share the same origin, "to divide/separate". 分かる now vaguely refers to something related to "understanding", and so does わけ. Today, わけ refers to basically anything that can help you understand an issue in front of you, which includes, but not limited to, 理由. わけ is closer to sense as in "it makes sense," or reason as in "that opinion is unreasonable!"
For example, as you may already know, 訳が分からない is a set phrase that means "that's nonsense/absurd!" or "I don't understand it a bit!" Another example is 訳知り顔 ("I-know-how-it-is look").
When わけ means the same thing as 理由, they are basically interchangeable. For example 遅刻の理由を教えて and 遅刻のわけを教えて is roughly the same. But unsurprisingly, わけ is more preferred in casual conversations because it's part of the native Japanese vocabulary. In addition, わけ tends refer to subjective or emotional reasons, whereas 理由 tends refer to objective or technical reasons.
Jisho.org defines them as:
1. conclusion from reasoning, judgement or calculation based on something read or heard; reason; cause; meaning; circumstances; situation
Usually written using kana alone
1. reason; pretext; motive
わけ: Irregular kana usage.
Judging from the definition of the dictionary, the two words are somewhat similar in their meaning.
However, their actual use or nuance is slightly different, and they are not always interchangeable. This difference is derived from themselves for some extent. However, I think that the difference comes mainly from the word where they were born. わけ is Yamato kotoba (大和言葉) or Wago (和語), which are native Japanese words, while 理由 is Kango (漢語) or Sino-Japanese vocabulary, that refers to that portion of the Japanese vocabulary that originated in Chinese or has been created from elements borrowed from Chinese.
The major difference between Wago and Kango reflected in わけ and 理由, in general, is that the former has a comprehensive meaning, is not official, suitable for colloquial use and having an emotional nuance, whereas the latter has a relatively strict meaning, is suitable for official usage and written language, and has a descriptive nuance.