I know that pollination takes place in flowers. After the pollen grains reach the ovules fertilisation takes place. This causes the formation of fruits. I had seen pollen grains in the anthers of flowers which don't form fruits. Why is pollen grain of any use to those flowers? Does fertilisation take place in such flowers? If it does what is the purpose?

It may simply be an accident, with no purpose. It could be that the pollen grains you saw were from a different plant and so could not fertilise the flower. It is also possible that the pollen or the flower itself could be infertile, perhaps due to a pesticide or a growth abnormality.