Aquarium water can turn cloudy due to bacterial growth, minerals leaching into the water, or presence of microscopic debris that the filter cannot remove. A bloom of bacterial growth is the most common cause, particularly in newer tanks. It can take months for a new tank's ecosystem to establish itself.
Even in a more established tank, anything that upsets the chemistry of the tank can cause water to turn cloudy. A dead fish, overfeeding or simple fluctuations in water chemistry can result in rapid growth of bacteria that makes the water cloudy. Over-cleaning filters and making considerable changes to the water can also upset the water chemistry and turn the water cloudy. Cutting back on feeding, vacuuming the gravel and making a small partial water change often clears up the tank within a few days.