Here's my theory:
As Mega Gengar, a portion of its body sinks into the ground. The lower portions turn a more reddish purple, and a third eye appears on its forehead. This new unblinking eye is oval and yellow and allows it to see into other dimensions.
The yellow eye of Mega Gengar allows it to see into other dimensions. Pretty cool, right? Well, according to here, ghosts aren't aware that they are deceased and actually "live" on a plane between our dimension and another dimension, which is accessible by going through the "Singularity", or going through the door to another world, such as a center of a black hole. Gengar can see the plane we live on, the dimension of life as well as the plane of death ghosts live on.
As for what Mega Gengar is based off, there are a few types of ghosts, and the type of ghost said soul is is actually parallel to what type of person they were in life. For example, a good person turns into a good ghost, protecting over haunted property while a mischievous person would turn into a mischievous ghost, tricking people and putting curses on people.
Now what Pokemon does a mischievous ghost sound like to you? The answer is simple: Gengar.
> Gengar is very mischievous, and at times, malicious. It enjoys playing practical jokes and casting curses, such as pretending to be one's shadow, then behaving erratically. When the quarry notices, the Gengar takes delight in its victim's terror.
In conclusion, Gengar is based off of a mischievous ghost, which, in turn, is based off of a mischievous person.
However, Gengar has been known to be loyal to a Trainer who treats it well.
This goes along with how a mischievous person can change into a good person with enough good treatment.
Bulbapedia Quotes