In the precursor to the Bible, the Gilgamesh epic, the tale was about the gods depriving humans of immortality, and the serpent was really trying to help humanity recover it. At one point, Gilgamesh does recover it but loses it again. Hence, we only have temporary lives. The Hebrew twists are interesting and ironic. We start out with immortality and lose it, thanks to the treacherous advice of the serpent. Ultimately, these tales were the "just-so stories" of ancients that tried to come to grips with the ultimate futility of personal survival.
Actually, the serpent is the bad guy in the Gilgamesh tale too: Gilgamesh Summary (very last paragraph).
Gilgamesh retrieves an herb from the bottom of the ocean that's supposed to impart immortality to it's user, but before Gilgamesh gets a chance to try it out, a serpent sneaks up on him while he's asleep and eats it.