When it comes to humans, there are behavior which can maximize the individual. And there are behavior which maximizes the group. Sin is typically connected to behavior which, although it might maximize the individual, it would not maximize the group or would have an adverse effect on the group.
For example, stealing might actually maximizes some individuals, since stealing is so much faster than working. This could give one more time to enjoy life. However, stealing will have a negative impact on the group, creating problems while increasing social cost.
If you look at the ten commandment, in the light of the individual versus the group, they reflect ways to maximize the group, but not necessarily the individual. Some individuals could be maximized if they could commit adultery, steal the husband's wallet and then kill him. But the group would suffer if everyone did this. Culture might maintain its stability if only a few people were allowed to maximize this way; king. The fair thing is nobody can do this; sin.
Lower level sins like gluttony could maximize the individual since food tastes so good and more allows one to enjoy food more. But in terms of the group, this can lead to social costs, since we now need to pay for health issues. That was the logic of sin.
The ideal was to find ways to maximize the individuals while also the group.