The reason Sam could give up One Ring was because he wanted nothing more than a small garden to tend to. He never desired anything more. Hence, The Ring couldn't tempt him.
Edit: To clarify, Sam never attempted to steal The Ring from Frodo. That is because Sam could resist the temptation of the ring because of his simple desires.