Cant remember if it was a book or a tv show (like Outer Limits/Twilight Zone) or movie. (I don't think it was a movie)
At least 20 years old. Whatever format it would have been in English in the USA.
A young man is a lone prisoner on a spaceship controlled by a computer. The ship seems old and in bad shape (wearing out). The computer continually directs him to repair equipment/replace parts/replenish resources. They have an antagonistic relationship. Anytime the man makes a mistake, is to slow, or breaks something the computer punished him. (Withholds food? Electric shocks? changes temperature or pressure?)
I think something major breaks, and the computer contacts another ship to try and get what it needs from it. The ships rendezvous and the other ship also has a prisoner on board, who is a young woman. The man and woman start talking while making repairs and they realize there are many ships out there each with a single human on them to maintain them.
Eventually they are directed to mate. And once the woman is pregnant, the ships separate, and the "couple" discover the reason for the baby, was one of the ships wanted to replace its human, when the baby got older, because its current prisoner was getting to smart or too hard to control.
I think the story ends with one of the humans trying to figure out how to hack the ship to gain control.