Quoting from Memory Alpha.
In The Eternal Tide, it is revealed that the Q Continuum manifested as a creative force to 'oppose' the destructive potential of the Omega Continuum after it was disrupted and the decay of the universe accelerated. Voyager is later able to slow down the decay to a more tolerable level—shortening the universe's lifespan by a few million years rather than by trillions—as the only way to completely halt and undo the disruption would have erased the Q Continuum from existence as their creative force was no longer 'needed'. Eternal Tide also reveals that there are at least six rules that the Q must obey, with number six being "Don't bring the dead back to life" as the consequences of such an action can be problematic as not even the Q fully know what happens after death.
So they have 6 rules to abide by, but this does not stop Q from messing with Enterprise from time to time. He seems to enjoy judging humans by their past misdeeds.
Quoted from source: http://memory-alpha.wikia.com/wiki/Q_Continuum
Apparently, this is a non-canonical work that I am quoting from. But interesting nonetheless.