At that time, it cost a lot of money to take the exam in Beijing, which the average peasant family could not afford.
In ancient feudal society, there were few wealthy families except gentry and landlords. Farmers have to pay land rent and bear heavy corvee. Businessmen and others have a low status. Think about it. It is said that the Tang Dynasty was prosperous, which is also relative to other dynasties.