I’ve been relaxing polylines on meshes for the past couple of years when this problem comes up. Here’s an old example:
There’s a few more approaches in that thread. The heat method might also be relevant, depending on your specific case. I know there’s a few implementations of this floating around the forum.