Odin is the king of the gods and Lord of Asgard in Norse mythology. Like many ancient gods, Odin is not outright evil, but some of his behavior is morally questionable at best even for the period of the time that he is is sometimes written as a villain.

Odin was venerated as the god who created the Earth, gave life to humans, and through the sacrifice of his eye and hanging himself on the World Tree for nine days acquired supreme wisdom and runic knowledge.  He gave humans the gifts of poetry, written language, and runic magic.  He could grant victory in battle and provided a heaven for fallen warriors: Valhalla.  He would sometimes travel the Earth in disguise testing humans either rewarding them or punishing them.  The story of Santa Claus in part traces its origin to him since he would once a year give gifts to good children.

Odin's dark side was perhaps a reflection of the grim world the Norse lived in. Odin was known to start wars on Earth to fill his army of the dead in preparation of Ragnarok, the final battle of the gods.  Odin was accused of turning on his favorites in battle or grant the undeserving victory to make sure his select warriors would go to Valhalla.  He was the only Norse god to regularly demand human sacrifice.  Instead of dealing with his enemies openly in the way Norse virtues espoused, Odin would often use underhanded trickery or magic to accomplish his goals.  Odin was primarily a god of nobles so Viking raids and conquests were often carried out in his name. 

Villainous appearances in Modern Media

Though often depicted in a heroic light Odin has his fair share of villainous appearances.  These instances often portray Odin as power-hungry, manipulative, and a disregard for anything that is unimportant to his plans.

In Neil Gaiman's American Gods, an American incarnation of the god named Mr. Wednesday orchestrates a war between new and old gods to feed himself.  This includes the murder of several gods and mortals including the protagonist's wife. 

Robert Rodi's Loki miniseries presents an alternate reality version of Marvel's version of Loki where Odin deliberately brought him up as an antagonist to Thor.

Odin is portrayed in a negative light in both the Iron Druid Chronicles and The Ballad of the White Horse.

The role playing game Scion has Odin willing to do anything to survive Ragnarok including switching bodies with his son Vidar, and act of supreme selfishness and cowardice.

In Mythical Detective Loki Ragnarok Odin acts as the main antagonist and seeks to kill Loki, but is somehow unable to do so himself, so he sends assassins instead. He was the one who commanded Loki to take Heimdall's eye.