So, in the Soultale universes, Sans and all of the human souls were erased from existence, meaning no human ever fell into the Underground. Asgore went mad and made a decree to harvest monster souls instead (Toriel taking Asriel and a group of monsters to the Ruins for safety due to being against the decree).
In order to keep the population up, Asgore essentially set up “reproduction camps,” where monsters, specifically strong monsters, would be forced to have children to be raised then harvested as souls for Asgore. The children would be put against each other, and the victorious one would absorb the weaker one’s soul to become stronger, and the cycle would repeat. Of course, some of the much stronger ones would be spared to become apart of the Royal Guard in order to continue harvesting the souls of the weak. Any form of treason resulted in an instant death.
Papyrus was second in command of the Royal Guard only after Undyne, so Asgore forced the two of them to have a child since they were both very powerful monsters (they are not in a relationship). Powerful parents = powerful children usually. Papyrus managed to convince Undyne to let him raise their son himself, where he did his best to keep him safe within the safe haven he and Grillby ran in Snowdin.
Then in SoulSwap, it’s essentially the same thing, but ofc, everything’s swapped. Sans and Alphys were forced to have a daughter, where he raised her in the safe haven he and Muffet ran.
So essentially, single dad vibes from Soul Papyrus (+ variants) and SoulSwap Sans. Not the ideal way for it to happen, but they love their kids very much and do much better on the Surface.
(If this is viewed as problematic, that’s the whole point. It’s supposed to be problematic. Asgore’s motive was to simply harvest as many powerful souls as possible, disregarding the wants of Monsterkind. To him, almost all of them would die anyway, so what would it matter? Undyne and Papyrus (and SS!Sans and SS!Alphys) understand that they did what they had to in order to survive and move past it. It was still very traumatic for all monsters involved.)