When Gotama, after leaving home, entered Giribbaja (Rājagaha) for alms, Bimbisāra saw him go and sent messengers to discover his whereabouts. They reported that Gotama was taking his meal under the shadow of the Pandavapabbata. There Bimbisāra visited him and requested him to share his kingdom. Gotama told Bimbisāra of his antecedents, that he was a Sākyan of Kosala and had renounced all pleasures, seeing ill in them (SN.vs.405 24).
Buddhaghosa explains (SNA.ii.381) that the Sutta was preached by Ananda at Jetavana, because he desired to give an account of the renunciation of the Buddha, similar to that of Sāriputta and others.
The Commentary adds (p.386) that at the end of the talk with the Buddha, Bimbisāra asked him to visit Rājagaha as soon as he had attained Enlightenment.