V'ger was once a simple probe (Voyager 6), created on Earth and launched out of the solar system. It evolved into a complex, powerful entity after it was pulled into an anomaly (likely a black hole). Voyager 6 emerged from the anomaly in what was believed to have been the far side of the galaxy, and fell into the gravitational field of a planet populated by living machines. These beings found Voyager 6 damaged by its travels, and the identifying plaque attached to the probe's exterior had been burned, leaving only the letters "V", "G", "E", and "R" legible; the inhabitants of the machine planet called the probe "V'ger".
By wandering around the universe and acquiring an enormous amount of information, V'ger became omniscient and godlike. He gradually developed an ego and self-awareness. In his search for finding his origin, V'ger decided to return to his creator and eventually Earth.
In the end, V'ger succeeds in communicating with the crew of the Enterprise, and disappears as high-dimensional being with machine intelligence, enormous knowledge, and a human mind by "merging" with his creator.