The answer has nothing to do with laws changing. Laws changed, from the beginning of time, this isn't one of them. If something is bad, then it's bad. The punishment of something may change. The time of prayer may change, but never in your prayers you would praise Satan. The direction may change but never it would never be that you can pray to an idol. Punishment may change, it may be lessened, may be increased but it would never be to the extent that it would be unjust. Drinking wine is forbidden because our intellects tell us it leads to rape/murder/unintended behaviors. Basically whatever that our logic forbids religions also forbids. Our logic is Allah's speaking messenger to us. Same as prophet. I mean ask yourself do we really mistreat our parents because Islam tells us?! OR because our God-given intellects tells us such but also religion says the same.
Allah has set some traditions, among them is that people are to be judged based on their public actions, not the actions of their hearts. This is the general rule/tradition. Though Allah may place an exception. His general rule is that fire burns, but he may place an exception for Prophet Ibrahim. His general rule is that no more than 4 wives, but he place an exception for Prophet Muhammad. His general rule is that God will not punish people for their non-public hypocrisy. There may be exceptions to that as well. But the story of Prophet Lut and Nuh weren't among them.
For a moment think that you're living in an Islamic environment and a prophet is there. If he's to judge people based on their hidden actions then it would be like: This person committed zina last night, that person drank wine, this person conspired against me, that person stole, that person did that...let's punish them one by one. And we're all sinners unfortunately (Him having being gifted Allah's knowledge is different from him using it).
Additionally this is a test for the prophets to know of the hypocrisy of others and still treat them based on their public actions.
If his wives were committing crimes/sins publicly only then the prophet would take action