In some sense, taking photos of rainbows will always rely on a bit of luck, but after learning a few things about how they work, you can at least up your odds. The way rainbows refract light into its component colors is actually a well understand scientific phenomenon, and make no pretense of being an expert. Bear with me as I go through the basics of it nonetheless.
First, you need some form of water droplets. Rain, especially fine rain or mist, works pretty well for this as you might suspect. Don't neglect the spray kicked up by water falls though; as you'll see below, since they're in a fixed location, rainbows can become very predictable with waterfalls. If you happen to be in Yellowstone, a geyser can do as well.
Next, whether you've noticed it or not, the sun will always be behind you when you see a rainbow. More specifically, you (your head, if you want to be really specific) will always be exactly on a line between the sun and the center of the arc of the rainbow.
Rainbows are more likely in the morning and evening when the sun is lower in the sky. If the sun is too high, the arc of the rainbow would be below you rather than in front of you. For waterfalls, it is often possible to look down towards their base where the spray would be concentrated, so it could be closer to mid-day. Rainbows caused by the rain are most likely close to sunrise and sunset since they tend to occur higher in the sky.
So, how big is the rainbow? The further away the rainbow is, the bigger it is. Specifically, the rainbow will exist along an arc that forms a 42 degree angle with the previously mentioned center line. By all means, refer to the diagram in order to help this make sense.
Rainbows are caused by refracted light and can be influenced by a polarizer. By rotating a polarizer, the rainbow can be made to completely disappear. By rotating it the other way though, you will darken the sky and make the rainbow stand out more.
Sounds at least a bit complicated, but in practice, it's really not. You need some form of water droplets or mist in front of you (or nearly in front of you), with the sun at your back. Keep an eye out, and see what you can find.