The Lord destroyed various peoples for violating basic morality and decency even if those people didn’t have the gospel at all. Not only did their religion not warn these people, but in fact, it seems that it was not uncommon for the Lord to destroy people for things that were actively endorsed by their religion. We see that laid out plainly when the Lord is speaking to the Israelites through Moses and tells them what practices he destroyed the heathen nations that preceded them for. We also see it in the destruction of Sodom and Gomorrah.
These people were destroyed for violations of basic morality. They were held accountable for violating basic morality, for certainly destroying people is holding them accountable, and therefore the Lord knew that, in their hearts, these people knew better. We are not held accountable for what we do no know.
Apparently basic morality is something that the Lord considers everyone to have sufficient light to be held accountable for simply by the fact that they have the light of Christ. And he has destroyed nations precisely for violating that light. Thus decency and morality are foundational parts of society. Everyone has enough light to live them, even if many choose to reject them.
We see this illustrated nicely in the Book of Mormon
Alma 30: 9 Now if a man desired to serve God, it was his privilege; or rather, if he believed in God it was his privilege to serve him; but if he did not believe in him there was no law to punish him.
10 But if he murdered he was punished unto death; and if he robbed he was also punished; and if he stole he was also punished; and if he committed adultery he was also punished; yea, for all this wickedness they were punished.
11 For there was a law that men should be judged according to their crimes. Nevertheless, there was no law against a man’s belief; therefore, a man was punished only for the crimes which he had done; therefore all men were on equal grounds.
There we see it clearly taught that adultery was a crime, like stealing, that people were punished for. It was punished as a crime, not as a religious matter, because morality is part of the basic principles of society.
Many people now have deluded themselves into thinking that since morality is taught in the scriptures this violates separation of church and state. But morality and decency are fundamental pillars of society, in addition to being religious principles. Thus we see it being punished here as a crime while the prophet makes it perfectly clear that doing so was not a violation of separation of church and state.
Now when most people are righteous, the society will choose laws that enforce decency and morality. They will make violations of these into crimes just as we find in the Book of Mormon.
But when the people become wicked, they are no longer listening to the light of Christ, they are no longer listening to their conscience, and so they choose to change the laws to allow for indecency and immorality.
And THAT is a major reason that when the voice of the people is choosing evil they are ripening for destruction. When the voice of the people is choosing evil they revoke laws for decency and morality, and then the floodgates open to that sort of misbehavior.
And that sort of misbehavior is exactly what the Lord said he destroyed the heathen nations that preceded the Israelites for. Once the laws no longer reflect the light of Christ that all men have, then the laws are changed to allow indecency and immorality, and the path is opened for the nation to follow the heathen nations down to destruction for violating the laws that God holds all men accountable for.