What’s the point of flirting?

I’m new here so bare with me. There was this guy I’ve known ever seen middle school he had a big crush on me for a long time it’s been a year sense we talked I’ve decided to text him to see how he’s been you know I’ve never had a boyfriend so I’ve been focusing on myself and trying to find myself so he said he was doing good and that he has a girlfriend which is his first I was happy for him but he started flirting with me knowing that he has girlfriend I’m like why are you doing that he said he doesn’t know I’m like do you have still have feelings for me he said he still do sum what idk if he was trying to get at me or what ? Comment down below if anyone doesn’t mind and see what should you say