Family background and early life
Parentage, disaster, and a barely spared young life
Liu Bingyi was born in 91 BC to Liu Jin, the son of then-Crown Prince Liu Ju, and his wife Consort Wang. As the grandson of the Crown Prince, Bingyi likely was born in Prince Ju's palace.
That same year, however, disaster would strike. With conspirators accusing him of using witchcraft against his father Emperor Wu, Prince Ju was forced into a rebellion, which was defeated. Prince Ju committed suicide, and Bingyi's two uncles died with him, although it was not clear whether they also committed suicide or were killed by soldiers. Bingyi's great-grandmother Empress Wei also committed suicide, and his grandmother (Prince Ju's concubine) Consort Shi and his parents died in the incident as well in the capital Chang'an. It is not completely clear whether they took their own lives or were executed, but the latter seems likely.
For reasons not completely clear, the baby Bingyi was spared, although he was imprisoned in a prison overseen by the Ministry of Vassal Affairs. He was put into the custody of the warden Bing Ji (丙吉). Bing knew that Prince Ju was actually innocent of witchcraft and took pity on the child, and selected two kind female prisoners, Hu Zu (胡組) and Guo Zhengqing (郭徵卿) to serve as his wet nurses and caretakers. Bing visited them each day to see how the child was doing.
Near the end of Emperor Wu's reign, there was an incident when magicians claimed that an aura of an emperor was appearing from Chang'an prisons. Emperor Wu ordered that all prisoners, regardless of whether they had been convicted or not and regardless of the severity of the charges, were to be executed. When the eunuch delivering the edict arrived at the Vassal Affairs prison that Bing oversaw, Bing refused to accept the edict, stating that no one who had not been convicted of a capital crime should be executed, and particularly not the emperor's own great-grandson. The eunuch filed charges against Bing for refusing to abide by the edict—a capital offense—but by that time Emperor Wu had realized his error and declared a general pardon. The prisoners in all other prisons were dead, but the prisoners at Bing's prison survived.
However, this incident made Bing feel that it was inappropriate for the young Bingyi to remain at the prison, and so he ordered one of his lieutenants to transfer Bingyi and Hu (Guo might have died by this point) to the city government of Chang'an. The city government refused to accept responsibility, and so Bing had to let them remain in prison. After Hu's sentence was over, Bing hired her out of his own pocket to continue to serve as a wet nurse for several months, before letting her leave. Later, the budget for taking care of Bingyi was cut off from the imperial clan affairs budget, and Bing took money out of his own salary to care for Bingyi. When he grew somewhat older, Bing heard that Consort Shi's mother Zhenjun (貞君) and brother Shi Gong (史恭) survived the incident, and so sought them out and had Bingyi delivered to the Shi residence. Lady Zhenjun raised him herself.
Several years later, Bingyi's granduncle Emperor Zhao found out that Bingyi was alive, and ordered that the Ministry of Imperial Clan Affairs take over the duty for caring for Bingyi. The chief eunuch at the palace Zhang He (張賀), who had previously been an advisor to Prince Ju before he was castrated by Emperor Wu in the aftermaths of Prince Ju's death, cared well for young Bingyi, and paid for his expenses and studies out of his own pocket.
Young adulthood and marriage
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 him. 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 depended on his wife's family and his grandmother's family for support, and he engaged a teacher to teach him the Confucian classics. He was a diligent learner, and he also had a strong sense of social justice. As a teenager, he had many friends from all walks of life and was able to see the dark sides of society and the suffering of the people at the hands of corrupt officials. He had a strong interest in hiking. Occasionally he was summoned to see Emperor Zhao. Pingjun bore him a son, Liu Shi.