This is a classic Prisoner’s dilemma. The best individual outcome is one betrayal, the best overall outcome is mutual cooperation and the worst outcome is mutual betrayal. In a prisoners dilemma, the “prisoners” are not allowed to talk to one another, as the game hinges on one being unsure of whether the other will betray them.
You find that while cooperation is the best overall decision to make, greed incentivizes betrayal and oftentimes both prisoners lose the game because neither trusts the other and both decide to betray the other. The whole point of prisoner’s dilemma is that it is always best to betray, regardless of what your fellow prisoner decides to do.