This is longer, and more technical, than can be effectively addressed by email. As you have perceived, it is extremely dangerous to get involved in substantial real estate (or other monetary deals) with someone married to someone else. You do not reveal enough about their legal relationship (in mid-divorce proceedings? Estranged only? Any paperwork or agreements?) to be certain, but yes, as a precondition to sinking money into such a deal, you should insist on there being a property settlement or equivalent agreement between your boyfriend and his spouse to insulate you from potential claims in their divorce. It is more complex than can be covered here; you should consult with a qualified family law specialist. You do not indicate if or why he has not already done such things with his existing spouse, but if he has not, that should be a huge red flag to you.
Answered on Jul 14th, 2018 at 5:48 PM