It was inevitable, at the moment he met Vader
Obi-wan was not going win that lightsaber duel.
Vader: When I left you, I but the learner; now I am the master.
Obi-wan: Only a master of evil, Darth.
Vader: Your powers are weak old man.
Obi-wan: You can't win. If you strike me down, I shall be more powerful than you can possibly imagine.
Vader was the Chosen One, trained by a Sith Lord. He was incredibly powerful. Obi-wan doesn't disagree with Vader; he just knows that he doesn't have to win the battle to win the war.
It was inevitable, at the moment they arrived at the Death Star
Vader: I sense something...a presence I haven't felt since...
...
Vader: Obi-Wan is here. The Force is with him.
Tarkin: If you're right, he must not be allowed to escape.
Vader: Escape is not his plan. I must face him alone.
Obi-wan separated himself from the others because he knew what would happen.
It was tactically necessary, at the moment he saw the Millennium Falcon
If Obi-wan retreated to the ship with the most powerful Dark Jedi in the galaxy in tow, it would have all but doomed the mission.
If Obi-wan stayed and resisted as long as possible, it would have meant Luke's death. Only once Obi-wan died, did Luke retreat to the ship.
Yoda: Only a fully trained Jedi knight with the Force as his ally will conquer Vadar and his emperor.
Without Luke (or Leia...), there would be no hope of winning against the Empire. Obi-wan had dedicated his life to watching, safeguarding, and training Luke; he wasn't about to renege.
Trap, or not
Even if Obi-wan somehow knew of the trap for the Rebels, it wouldn't have changed anything. The Jedi were the only real threat to Vader and the Emperor. If Obi-wan escaped on the Falcon, Vadar may have decided to remove the larger threat, and save the Rebel base for later.
It was best
As good a training record as Obi-wan had (or not), Yoda was going to be the better teacher. Whether Obi-wan was alive or not, Luke would have traveled to Dagobah and be taught by Yoda.
But as a "powerful" omnipresent Force ghost, Obi-wan could guide him wherever he was.