Why do we see sometimes see a rainbow around the moon or sun.

Because the light often refracts the particles to create the colors of the rainbow.

Since this is not my area of expertise, I searched Google under the key words "moon halo" to get these possible sources:

http://antwrp.gsfc.nasa.gov/apod/ap000515.html
http://home.hiwaay.net/~krcool/Astro/moon/moonring/
http://ww2010.atmos.uiuc.edu/(Gh)/guides/mtr/opt/ice/halo/22.rxml

Under "moon rainbow," I found:

http://www.time.com/time/magazine/article/0,9171,760103,00.html

Under "lunar rainbow," I founde:

http://en.wikipedia.org/wiki/Moonbow
http://www.eo.ucar.edu/rainbows/
http://www.atoptics.co.uk/rainbows/moonbow.htm

In the future, you can find the information you desire more quickly, if you use appropriate key words to do your own search.

I hope this helps a little more.Thanks for asking.