What is the origin of the phrase "play a part/role"?

The literal, original meaning of the expression “play a part/role” comes from the theatrical sense of characters played by actors on the stage.

The meaning of “role” in the sense of “part played by a person in life” derives from French roll (of paper) on which an actor's part is written, and dates back to c.1600.

Others figurative senses:

Meaning "function performed characteristically by someone" is from 1875. In the social psychology sense from 1913.

(Etymonline)