For colors to work well together you need one of two things: color contrast or complimentary colors. To understand this, look at a color wheel.
Note that yellow and blue are on opposite sides of the color wheel, as are green and red. Color opposites create color contrast. When you have color contrast it makes those colors pop against each other. Your eye gets drawn to the part of the image where those two colors meet. It's bold and striking.
If you were to make a "Y" and draw it across the color wheel, you'd find complimentary colors. It takes three colors working together to do this. Generally, softer colors work better. Complimentary colors occur much less frequently than contrasting colors, so it's more difficult to make a color image this way (but far from impossible).
Here are two examples of images with color contrast that I took yesterday using a Nikon S8100:
|No Dumpster Diving - Tehachapi, California|
This photograph is about color contrast and the written message.
|Christmas Bulbs - Tehachapi, California|
This photograph is about color contrast, repeated shapes, and holiday sentiments.