Warning: Long answer ahead (tl;dr I'd be surprised if it wasn't biological)
I always see answers that point to "scrotum-squashing" or "asserting dominance as the alpha male", but I think anatomy is a more relevant source. I don't experience pain when I push my legs together, and I think pointing to subconscious conditioning is too hasty. What I did feel was my leg muscles getting too tired to justify sitting that way.
There are so many differences between male and female pelvises that it's hard to believe there is no biological differences in hip adduction (force needed to push your legs together). I found it surprisingly difficult to find scientific information on this (it might have been easier if I studied medicine and knew exactly what scientists were talking about). Looking at diagrams, I think it could be some leverage issue with the male pelvis tapering more at the leg joints so the tendons pull the legs apart. It could also just be weaker or smaller adduction muscles in men just due to different geometry, i. e. it's easier for women to pull their legs together. Like all things in science, it's probably way more complicated than I think it is. If it is biological, it could be justified by the scrotum-cooling idea. Scottish men who wear kilts are known to have higher-than-average fertility rates, probably because their testes don't overheat. So differences could be sustained by sexual selection.