The theme is the unviersal truth that a work of fiction embodies. Macbeth's famous soliloquy "Tomorrow, and tomorrow and tomorrow" of Act V, for example, has as its theme the illusionary nature of life, a theme that capsulizes the visionary drama that Shakespeare has written.
The theme of a piece of literature is what you get when you ask the question, "Beyond the plot, what is this work about?"
Themes can be developed in many ways. The simplest description of "theme development" is repeititon. When an idea comes up repeatedly or a certain type of decision is forced upon characters multiple times, we begin to see the ideas at work behind the plot. These ideas constitute the theme(s).
We wouldn't say that there is a "purpose in using theme", usually. Unless the theme is specifically political or oriented by a pointed concept, the theme will be better understood as a complex or wide-ranging idea that is expressed and explored in a work.
For instance, the major theme in Waiting for Godot is that humans can never reach outside of the finite realm of the human mind to grasp the meaning behind the world or to encounter ultimate, existential knowledge.
The theme is developed through dialogue that discusses an off-stage character attributed with certain qualities and it is developed through discussion of the arbitrary and chaotic meaninglessness of the present characters' situations.
A theme is a statement of the meaning of a piece of literature. What is the ultimate point that the author is trying to make? What "truth of life" is presented through the work? In order to figure out the theme, it is important to determine the conflict(s) in the work because the two go hand-in-hand. What internal and/or external conflicts is the main character facing? How does he handle them? What is the result? What does he learn? As you answer those questions you are learning about what the play is about, and that is the theme. This would true of any piece of fiction: novel, story, or play.
Theme is the message the play wants to convey. Some people describe it as a moral or lesson, but it is not always directly a lesson. A play will build theme largely through dialogue. Characters can say things directly related to the theme, as the events happen around them.