Created by Stan Lee, Jack Kirby and Vince Colletta, Ego was introduced in 1966's "Thor" #132, in which the god of thunder battled the mysterious alien Rigelians, who had captured Earth in a "planet lock." Just as Thor was close to finding a way to break Earth free, he was offered a deal by the Rigelians, who warned him of a greater, not just to the planet but to the entire universe: the so-called "Black Galaxy," which destroyed everything that entered it.
Fearing this Black Galaxy would soon expand beyond itself, destroying everything in its path, the aliens said they would release Earth if Thor would take care of this looming threat. Thor agreed, and headed into the Black Galaxy along with a Rigelian Recorder robot (to document what happened in case Thor never came back). It's very telling that this story arc closely followed the introduction of the planet-devouring Galactus earlier in 1966. Kirby and Lee were clearly at a point in their career where the artist's interest in the universe was informing a great deal of their work. So at the end of "Thor" #132, the thunder god and the Recorder entered the Black Galaxy and discovered a talking planet named Ego.
The next issue, Ego introduced himself and explained how powerful he was, noting that Thor was essentially beneath his notice. He then explained he would assume a humanoid form and defeat the hero (perhaps this could be a basis for Kurt Russell's character in "Guardians of the Galaxy Vol. 2"). If he succeeded, he would know he could easily conquer the universe. Thor managed to anger Ego enough that he dropped the humanoid form and instead began to attack with his entire living planet body, sending humanoid "anti-bodies" to kill the god of thunder. Thor managed to fight them all off and then headed to the arteries of Ego, where he called down enough lightning and thunder to defeat the entire planet. That led Ego to vow never to leave the Black Galaxy and give up his dreams of conquest.
We next saw Ego two years later when Kirby, Lee and Colletta created a two-part story in which he was discovered by Galactus. If Galactus liked to consume normal planets, you can only imagine how much he would want to devour a living one. In this storyline, Thor teamed up with the Riegelians as well as the Wanderers, who had been homeless since their planet was destroyed by Galactus long ago. After a devastating battle between Ego and Galactus, Thor stepped in with the help of alien technology to harness his Asgardian power to drive Galactus away. In gratitude, Ego agreed to allow the Wanderers live on his surface.