It's true - each of the main characters in Spongebob Squarepants is subtly based on one of the seven deadly sins.
It was confirmed as a surprising revelation as part of the audio commentary for the episode "Plankton!" on the first season DVD boxset. It has never been clarified which characters represent what. However, there has been plenty of speculation.
1) Envy: Plankton
Logical, considering Krabs' good fortune and wealth, while his archrival, Sheldon Plankton, contrasts him with hard luck and failure.
2) Gluttony: Gary
Throughout the series, Gary doesn't do a whole lot other than eat and meow, the latter usually being because he's hungry.
3) Greed: Mr. Krabs
The most obvious out of all of them. Constantly thinking of ways to turn a profit, even if it involves taking advantage of his friends.
4) Lust: Spongebob
This isn't lust in the sexual sense, but rather the alternative definition of "a passionate desire for something". Taking that into consideration, it's easy to see that Spongebob is a very lustful character. He lusts for life and loves the affection from both friends and foes, often stopping at nothing to finish a task.
5) Sloth: Patrick
If the fact that he lives under a rock isn't convincing enough, in the episode "Big Pink Loser", he's given the award "doing absolutely nothing longer than anyone else."
6) Pride: Sandy
From Sandy Cheeks in Texas, she's a squirrel who is proud of her heritage and the fact that she's the only land animal that lives in Bikini Bottom.
7) Wrath: Squidward
Squidward has a general distaste for life and often expresses dissatisfaction for his job. Spending most of his time angry, he usually hates Spongebob too.
Again, these are only speculation, but the majority of people seem to agree that these are the most logical attributions.