This is something confused by many students.
Actually, a rainbow isn't formed due to the Total Internal Reflection of water droplets. It's formed due to the refraction(or better to say dispersion) of white light from the sun. And this dispersion happens when the sunlight strikes at the surface of the water droplet(i.e., at the air-water interface) As you know, light rays bend towards the normal when it travels from a rarer to denser medium. So, when a polychromatic light like our sunlight(i.e., white light) travels from air to water, it bends towards the normal. But what happens is, since there are many wavelengths of light in white light, each of them bends according to their own wavelength and hence we see them separately. Now if these separated light rays, strike the water-air interface of the water droplet, they may or may not undergo total internal reflection according to their incident angle. If it does undergo, then it will never come out of the droplet. We know that a part of light is reflected when a light ray undergoes refraction. It's that same internal reflection.
Image source: www.metoffice.gov.uk.com
To be more concise, when white light strikes at the air-water interface of the water droplet, it gets dispersed into light waves of different wavelengths due to refraction. But, we can see that light rays of longer wavelength (like red) gets deviated comparatively lesser than lights of shorter wavelength(like blue). So, after the first refraction, you can see that the red light is at the top and the violet light at the bottom. After the internal reflection, due to the curved water-air interface of the water droplet, the light rays get arranged vice-versa on their way back to the water-air interface. And now, you can see that violet is at the top and the red at the bottom.
Now the reason for the arrangement of the colors in rainbow is the is the degree of inclination of sunlight. The water droplets at the top are more likely to get less inclined rays of sunlight therefore the red light which is at the bottom of the spectrum is more likely to reach our eyes. Similarly, the water droplets at the bottom of the rainbow will probably get more inclined rays of sunlight hence the violet light rays will reach our eyes.
Image adapted from www.rebeccapaton.net
If you're still not satisfied with my answer, you can go check this out. It's an article by Lock Haven University.