Liu Bei刘备 was a native of Zhuo涿 Commandery in Youzhou幽州.
At that time there were many clans of Liu surname in Zhuo Commandery, all of them belongs to the descendants of the Western Han Dynasty(202BC-8AD). The details are like this:
Liu Bang,the Emperor Gaozu of Han(202BC-195 BC) ,established Western Han Dynasty, after Liu Bang's death, it entered the era of Empress Lyu's(195-180AD) reign吕后称制, there were three puppet emperors, it was only after Empress Lu's death that the Great Han Empire was put into the right track, the successor was Liu Heng刘恒, the fourth son of Liu Bang, Emperor Wen of Han(汉文帝180-157BC).
After Liu Heng's death, his eldest son, Liu Qi刘启, assumed the throne as Emperor Jing of Han(汉景帝157-141BC), Liu Qi had 14 sons, including Liu Yu刘余, the fourth son as the Prince Gong of Lu鲁恭王, Liu Fa刘发, the sixth son as the prince Ding of Changsha长沙定王, Liu Sheng刘胜, the ninth son as the prince Jing of Zhongshan中山靖王, and Liu Che刘彻, the 10th son as the prince of Jiaodong胶东王.
After Liu Qi's death, Liu Che took the throne as Emperor Wu/Martial of Han(汉武帝141-87BC), and this lineage became the orthodoxy of Western Han Dynasty. But 150 years later, Wang Mang王莽 usurped the throne and the Western Han Dynasty fell, so Liu Che's lineage faded from the stage of history.
Liu Xiu刘秀, the founding emperor of the Eastern Han Dynasty, was the fifth generation grandson of Liu Fa刘发, the prince Ding of Changsha,6th son of Liu Qi. And after the establishment of the Eastern Han Dynasty(25-220AD), Liu Fa's lineage became the orthodox one, from Liu Xiu, the Emperor Guangwu of Han(汉光武帝25-61AD), to Liu Xie刘协, the Emperor Xian of Han(汉献帝189-220AD), all of them came from this lineage.
The entire Eastern Han Dynasty is still a direct descendant of Liu Qi, but not from Liu Che, the Great Emperor Wu/Martialof Han.
During the Three Kingdoms period, Liu Biaol刘表, the provincial governor of Jingzhou荆州, Liu Yan刘焉 and Liu Zhang刘璋, the father and son, the provincial governors of Yizhou益州, were both descendants of Liu Yu, the prince Gong of Lu,4th son of Liu Qi, they were also direct descendants of Liu Qi.
While Liu Bei was a descendant of Liu Sheng, the Prince of Zhongshan , 9th son of Liu Qi,he had no direct blood relationship with the Emperors of the Eastern Han Dynasty. That's why Liu Bei always talked about his ancestor Liu Bang, but never mentioned Liu Xiu, the founder of Eastern Han.
However,Liu Sheng, prince Jing of Zhongshan, was very capable and would surely be praised by Liu Bang , for he gave birth to more than 120 sons, who made great contribution to the reproduction of the Liu clan, including one of his sons, Liu Zhen刘贞, Marquis of Lucheng (county)陆城(县)侯, whose fiefdom was in Zhuo commandery.
At the Later Eastern Han period, the number of the Liu clan in Zhuo commandery was already very large, so some historical materials say that Liu Bei was an impostor of royal descent, which is not true, as long as Liu Bei's surname name was not changed by himself, then there is no question about his identity of being a royal descent.
But the problem is, after nearly 400 years of prosperity, At the Later Han period, the Liu clan members, at least more than 100,000, relying solely on this identity,was useless, Liu Bei's grandfather Liu Xiong刘雄 had been a county magistrate, but because of the early death of his father, so Liu Bei's young life is very hard, until the elders of the same clan to obtain financial support, so as to be able to get out of poverty.
Liu Bei studied with Gongsun Zan公孙瓒 under the tutelage of Lu Zhi卢植, and by virtue of his benevolence and chivalry, Liu Bei gradually became famous in the countryside.
At the Later Han period, Zhuo commandery was full of talents, besides Liu Bei, Lu Zhi and Gongsun Zan, Liu Bei's early subordinates Zhang Fei张飞 and Jian Yong 简雍were also from Zhuo commandery , while Guan Yu关羽fled from his hometown due to a crime he committed in his early years, and only then he strayed to Zhuo commandery .
By the way, Liu Bei with Guan Yu and Zhang Fei, they did not swear to be brothers in history. However, the historical book " Records of the Three Kingdoms" says that they did have a brotherly bond with each other, sleeping together every day, while Guan Yu and Zhang Fei guarded Liu Bei all day long and were loyal to each other. In addition, Zhang Fei was a few years younger than Guan Yu, so he treated Guan Yu like an elder brother.
After the outbreak of the Yellow Turbans Uprising, Liu Bei was appointed as the Sheriff of Anxi安西 County for organizing the volunteer army to suppress the uprising, but he soon abandoned his post and fled because of whipping the officer inspector(in the novel,this whipping officer inspector thing was done by Zhang Fei,but in the real history,Liu Bei did it himself).
Soon Liu Bei was appointed as an official of Xiami下密 County because of his success in rounding up the thieves, and then he resigned from his post to become the magistrate of Gaotang高唐 County.
When the alliance army were fighting against Dong Zhuo董卓, (yes,Liu Bei also did take a part in the alliance army against Dong Zhuo)Liu Bei was defeated by the Yellow Turbans and had to leave Gaotang to join his senior brother, Gongsun Zan, who asked him to assist Tian Kai田楷, the provincial governor of Qingzhou青州, to defend Yuan Shao袁绍.
Soon after, at the age of 30, Liu Bei was promoted to governor of Pingyuan平原 commandery in Qingzhou, and during this period, he got to know Gongsun Zan's general, Zhao Yun赵云, and the two of them built up a deep bond.
Liu Bei served in Pingyuan for three years, and built up a good reputation for his love for the people and kindness, and gradually became famous in Qingzhou and Xuzhou徐州. At that time, some people in Pingyuan commandery looked down on Liu Bei's background, so they paid an assassin to assassinate him. Liu Bei did not know the identity of the assassin, and treated him with courtesy as usual, and the assassin was touched by Liu Bei's benevolence, and eventually left because he couldn't bear to do harm to him.
During this period, Kong Rong孔融, the commanderial Governor of Beihai北海,who was besieged by the Yellow Turbans, asked Liu Bei for help. Liu Bei was flattered and replied happily: “WoW!I can’t believe that a famous scholar like Kong Rong actually knows my name? ”Liu Bei then sent 3,000 soldiers to rescue Beihai, the Yellow Turbans heard about it and retreated, and Kong Rong was grateful to Liu Bei.
The name of benevolence and righteousness not only saved Liu Bei from death, but also made this young man in his early 30's quickly became famous throughout the Empire, and from then on became a label that he could never tear off for the rest of his life.