In most cases, they are the same.
In my humble opinion，they are slightly different at these cases：
1. 理解 lijie is a bit more literary, while 明白 mingbai is a bit more colloquial.
2. 理解 has a sense of empathy, for example, 我不赞同他的行为，但我能理解他。
3. 理解 is used when comes to understand something a bit difficult, like science or literature, means comprehend / comprehension, fox example, 理解能力 the ability of comprehension.