We can often think of past loves - it doesnt detract from the love we have for our present spouse. Often something has triggered these thoughts - perhaps your husband didnt quite treat you as you expected and your sub-consciously wondered if it would have been better with your ex. Work on your marriage if you do not want it to fail. The grass can always seem greener on the other side of the street.
Maybe he set the standard for many areas of your relationship, but not the ones that matter.
There are particular no answers that why you dream certain things.. But the only logical answer for you is.. You are thinking a lot about your ex.. And you are still not over him