This 'random kid' stuff is absurd. The child is five or older. For all these years you have been calling it 'my son' or 'my daughter', and it has been calling you 'papa' or 'dad'. You've changed its diapers, sang it to sleep, fed it, clothed it, played with it, taught it words, hugged it after a bad dream. You are its world.
If after all that time it turns out to be not genetically yours I'm sure that hurts. Probably hurts a lot, if it's a betrayal by your partner.
But to pretend that it is in any way the same thing as the government assigning you 'a completely random child' is an absurd hyperbole. Five+ years is a decently long time to be (or think to be) someones father, but for the child that is literally its whole life.
So tell me, if it turns out after 5 years your child isn't biologically yours, you would just abandon it? It's been a nice few years but now it's over, leave to buy cigaretes and never return? And you think remaining its father is the un-manly thing to do? That sounds completely insane to me.