The term from which the word chancellor was derived originally applied to an individual whose duties were no more onerous than to stand at the railing of a court, back in the days of the Roman Empire, to protect the court from the press of the people.
He was just an usher. His title came from the place where he stood, at the railing or latticework. Cancelli was the name of that railing, hence the usher was known as cancellarius.
At the breakup of the Roman Empire, the functionary represented by the title became of great importance in the Roman-German Empire and the kingdoms of the West.
In England, where the title was first canceler, and ultimately became chancellor, through French influence, it became the title of the highest judicial officer of the crown.