How does Martin become the companion of Candide?
This occurs in Chapter 19 "What Happened to them at Surinam and How Candide Became Acquainted with Martin". While in Surinam, Candide sends the last of his wealth away with Cacambo, & finds himself alone & miserable. So, he decides to hold a contest:
He made it known in the town that he would pay the passage and board and give two thousand piastres to any honest man who would make the voyage with him, upon condition that this man was the most dissatisfied with his state, and the most unfortunate in the whole province.
Candide is overwhelmed with the response, mentioning that Pangloss would be hard-pressed to demonstrate the validity of optimism in Surinam. Finally, he decides on one man.
This philosopher was an honest man; but he had been robbed by his wife, beaten by his son, and abandoned by his daughter who got a Portuguese to run away with her. He had just been deprived of a small employment, on which he subsisted; and he was persecuted by the preachers of Surinam, who took him for a Socinian. We must allow that the others were at least as wretched as he; but Candide hoped that the philosopher would entertain him during the voyage.
So, although Martin may not have been the most miserable among them all, Candide is looking for companionship, & thinks Martin will best provide that. So, their friendship begins.