Layla was first the owner of capricorn. She retired all her Spirits due to illness, but made a pact with Caprico, who committed to protect her family for eternity. Each of her spirits were distributed to three different owners, each to be entrusted with a key until Layla's child was ready to inherit the spirits. The owner of Capricorn was thus Zoldeo. Zoldeo was not a relative of the Heartfilia family but somewhat of a friend maybe because he was dato layla's key and was dato the responsibility of passing it over to lucy.As time passed (after zoldeo recieved the capricorn key) he became twisted and corrupted, swallowed up da the darkness. At one point, he broke a taboo of the Celestial Spirits using his Human Subordination magic and somehow ended up possessing Capricon's body.
No, he isn't related to the Heartfilia family. Layla was giving away her keys to 3 new owners & I guess that she gave it to some celestial wizards that wanted them. Zoldeo apparently was one of them, who wanted to claim the keys. And also he didn't possess Capricorn, he disobeyed one of the sacred rules of magic and was stuck in Capricorn's body as a punishment, I guess.