The origins of lawyers and the first founders of law make their appearance in Ancient Greece.
However, the law around fees was often violated but the law was never abolished so it was impossible for these early lawyers to establish a formal profession. But in ancient Rome, Emperor Claudius legalized the legal profession and even allowed lawyers (also known as advocates) to charge a limited fee.
Also, the early legal profession was stratified with lawyers that specialized in the law and others that specialized in rhetoric which meant that clients might have to visit two different lawyers to handle their case. But this specialization also meant that Roman laws became more precise since there was an entire class of people who focused on just studying and understanding the law.
Before this time, any ordinary citizen could call themselves an advocate (lawyer) but once the profession became more regulated, there was a very high standard to meet before being allowed to work as a lawyer,
An interesting side note: In ancient Rome, notaries did not have any legal document management skills — in fact, they had no legal training and were barely literate. But they could draft wills, conveyances, and contracts cheaply. They were also known for drawing simple transactions in convoluted legal jargon as a way of making more money since they were paid by the line.
Lawyers in medieval times found themselves struggling to make a living as the legal profession collapsed in the western world. But the profession did have a resurgence eventually but mostly in a form that served the church and its laws.