In The Bacchae, the theme of madness pops up constantly. The god Dionysus has a way of driving people mad and making them wild – really wild, like ripping-their-own-children apart wild. The play could be seen of as an exploration of the bad things that can happen when the irrational and the rational aren't both allowed to exist in the lives of humanity. In other words, the play may just propose the theory: a little madness now and then is a good thing.
The Bacchae links madness with religious ecstasy.
When Dionysus allows Agave to regain her sanity it's more of a punishment than her original madness.