A massage is basically for relieving muscle tension by pressing and rubbing the part of the body that's affected & for similar types of purposes, and sex is not for this kind of purpose.
Sex is something that's done by one organism (the male) to transfer biological information (genes) to another organism (the female) of the same species in order to reproduce, in the form of semen - which is filled with sperm.
The repetitive thrusting that occurs during copulation with humans and other animals that do the same thing serves a specific purpose that can be explained by science. In at least humans, this is done to remove the semen that was provided to the female, by prior male partners, with the coronal ridge of the male sex organ, so much more of their own semen is closer to the egg for the sperm it contains, and in order for their sperm to be the first to reach it.
You can learn more about this here:
https://www.sciencedirect.com/science/article/abs/pii/S1090513803000163
It's a competition like a football game; the uterus is the playing field, and the egg is the end zone.
Here's an article that talks about different things done by other animals to compete:
Astonishing Ways Animals Ensure Their Sperm Win
There may be a possibility that certain sperm cells are specialized for purposes other than fertilization, and some are referred to as "kamikaze sperm" - although apparently studies aren't showing evidence to support this.