When Emperor Yuan was born as Liu Shi in 75 BC, his parents Liu Bingyi and Xu Pingjun were commoners without titles. Bingyi was the great-grandson of Emperor Wu, and his grandfather Liu Ju was Emperor Wu's crown prince, until he was forced by Emperor Wu's paranoia into a failed rebellion in 91 BC while Bingyi was still just an infant, in the aftermaths of which Prince Ju committed suicide and virtually his entire family was wiped out. Bingyi was spared because of his young age, but became a commoner and survived on the largess of others. One of whom was chief eunuch Zhang He, who had been an advisor for Prince Ju before his rebellion, and who was punished by being castrated.
Circa 76 BC, Zhang wanted to marry his granddaughter to Bingyi, but his brother Zhang Anshi (張安世), then an important official, opposed, fearing that it would bring trouble. Zhang, instead, invited one of his subordinate eunuchs (who had also been castrated by Emperor Wu),
Xu Guanghan (許廣漢), to dinner, and persuaded him to marry his daughter Xu Pingjun to Liu Bingyi. When Xu's wife heard this, she became extremely angry and refused, but because Zhang was Xu's superior, Xu did not dare to renege on the promise, and Bingyi and Pingjun were married, in a ceremony entirely paid by Zhang (because Bingyi could not afford to). Zhang also paid the bride price. After marriage, Bingyi heavily depended on his wife's family for support.