Instructions
Wait until it is after midnight in the game. This time of night is when the ghosts of dead Sims are most likely to show up, but their appearance is not guaranteed. Ghosts will haunt at random, so you may see a ghost one night but not the next. If one or more of your living Sims are awake while the ghost is there, they can interact with the ghost just as they would with another living Sim.
Create a ghost yourself if you'd rather not wait for one to show up in the middle of the night. At a random point after the death of a Sim on your lot, one of the living Sims will receive an opportunity called "Oh My Ghost!" Once this opportunity appears, pick up the gravestone or urn of the dead Sim and place it into the living Sim's inventory, then go to the science lab. When your living Sim emerges from the lab, she will be accompanied by the ghost of the dead Sim. The advantage of creating a ghost this way is that the ghost is a fully playable Sim.
Make a ghost baby. Have a living female Sim develop a relationship with a male ghost until the option to "Try for Baby" becomes available. If the female becomes pregnant and has a baby, there is a 50 percent chance that the baby will be born a playable ghost.