I think it's a control thing or a power thing.
They want to feel wanted, and one way of doing this is by trying to make you jealous and provoking a reaction.
I don't think its a very nice thing to do, and may be the signal of an unstable relationship.
Another reason might be to test your commitment. Again, if they are insecure - then they will try and see if you are outraged by them flirting with another girl. If you don't seem to mind, they will begin to worry that you are not worried about losing them.
Sometimes they won't even flirt with another girl, but rather ignore you to spend time with friends. This can still cause jealousy and, if they do it willfully and know they are hurting you then this is a wicked thing to do.