This verse emerges from a discussion between the Buddha and the Kosala king Pasenadi, who generally feels secure behind his four-fold army (elephant, chariot, cavalry and infantry divisions), his conjurers and his treasury. The Buddha asks him to imagine a situation — the fantastic closing-in of four mountain ranges — where all his royal resources will not help him meet the foe.
Such is the situation in which we actually all find ourselves — rich or poor, aristocrat or laborer — though we are reluctant to face it. How do we respond to the inevitable onslaught of aging and death? The answer given in the body of the sutta is "What else is there to do, save to live righteously and justly and to work good and meritorious deeds?" The verse summarizes this phrase by saying one should have confidence (another way of translating the word saddham ) in the triple gem and practice the Buddha's teaching.
Ever practical, the Buddha often points out that in this way we are covering our bets: there are immediate benefits in this life, and in the next our chances are better of emerging well-off.