Under the right conditions, white sunlight can be split into its individual colors — and that’s when a rainbow can appear. So how does it happen?