Temperature affects the way your brain works, and fever can produce waking hallucinations and vivid imagery as well as nightmares.
Some people find that too much spicy food leads to nightmares, and this may also be because it raises body temperature. Our temperature varies throughout the day, and is especially low just before the onset of sleep. Then, during REM (rapid-eye-movement) sleep when most dreams occur, temperature control is very poor.
So having a fever can lead to a much higher temperature than normal during REM sleep, and it is this that causes the over-activity manifested in our minds as vivid and scary dreams.