Sex is for procreation; even when done for sport, the biological studies show that changes happen hormonally that increase the chances of reproduction. Ergo, even when you don’t think sex is for reproduction, nature made it so that it is.
Sex is - barring IVF - required for procreation. But saying that sex has a purpose implies a creator. And once you require a creator then you're off in the land of theology and biological studies take a back seat.
Evolution is a process. It can't assign a purpose to anything, because "purpose" doesn't exist outside the minds of people, similar to "justice" and "hope."
The "purpose" of sex is whatever we choose it to be.