Why is he asking me if we can be just friends?

Over text he writes his back with his ex his been on and off with years. I wrote to him I just had a breakup not long ago not looking to go further than a friendship. in person he was checking me out smiling at me just standing their so I smiled back to be nice then he kept looking at me like he can’t take his eyes off me. We told each other that we both attractive Than he wrote his sorry he back with his ex, his happy with his beautiful girlfriend his going be with her forever I told him that’s good he asked if we can be just friends I answered yes. On social media he acts single so people wouldn’t know his relationship status.
Why is he asking me if we can be just friends?
Post Opinion