When we are sleeping, there is a brain mechanism that stops the neural activity associated with dreaming from triggering speech or body movements. But this system isn’t perfect, and sometimes signals can get through. This can lead to mumbling and groaning and sometimes even proper speech (and sleep walking).
The content of sleep talking can be complex and is usually grammatically correct. It may be influenced by recent events in the sleeper’s life, but can be strange and nonsensical. Sleep talking is usually benign, although stress and other psychological problems can increase the likelihood of it occurring.