I can't get away from a belief that laws and morals are not REALLY established by social compact. Obedience to laws is by social compact, but the laws are not created that way. They are established by those who have power withinof the community by lineage, or military or economic might.
I might have said some of what Dave said differently, but I think this part I quoted is especially correct. Some laws may actually be by compact but the evolution of the laws as set out by Lucretius makes clear that force has always been a factor and is a factor that never really goes away no matter how much we might like it to do so. if we perceive that there is no actual thread of someone punishing us for committing a crime, that's going to make a big difference, and I presume that's why Epicurus says that such circumstances (as when we are confident we won't ever be discovered) pose more difficult questions.
One thing is for sure - there are no supernatural forces that will punish us, so there have to be real-world factors in play to cause us real concern.