You might not want to be the one at the party who takes the last piece of cake, but then again, it would be a sin to let it sit there, uneaten. A sin is a deeply regrettable action.
The most common definition of sin is religious: it's an immoral act against God or divine law. Any serious offense, even if it's not religious, can be called a sin, and so can something less serious if you're talking about it in a joking way, as in, "You've got to buy those shoes — it would be an absolute sin not to." In math, sin is the abbreviation of sine, the trigonometric function.