You're swimming in the sea, and all of a sudden a jellyfish appears from nowhere and stings you. Why did they do it?
Jellyfish use their sting to capture prey and act as a defence mechanism. When their tentacles encounter a human or other sort of prey they reach out and fire out harpoon-like structures containing a neurotoxic venom. It will paralyse their prey but in the case of us lowly humans it will just really hurt.
Also, peeing on a jellyfish sting will not make it any less painful. So if a friend offers to help you can kindly tell them thanks but no thanks.