At least in the US, where a presidential pension was only instituted in 1958, it was seen as embarrassing for a former president to be struggling financially. Per Wikipedia:
Upon leaving the presidency [in 1953], [Harry S.] Truman ... taught occasional courses at universities, including Yale, where he was a Chubb Fellow visiting lecturer in 1958. In 1962, Truman was a visiting lecturer at Canisius College. As a former president, Truman decided that he did not wish to be on any corporate payroll, believing that taking advantage of such financial opportunities would diminish the integrity of the nation's highest office. He also turned down numerous offers for commercial endorsements.
Once Truman left the White House, his only income was his old army pension: $112.56 per month (equivalent to $1,089 in 2020). Former members of Congress and the federal courts received a federal retirement package; President Truman himself ensured that former servants of the executive branch of government received similar support. In 1953, however, there was no such benefit package for former presidents, and he received no pension for his Senate service.
...
In 1958, Congress passed the Former Presidents Act, offering a $25,000 yearly pension to each former president, and it is likely that Truman's claim to be in difficult financial straits played a role in the law's enactment.
The current presidential salary is $400,000 (but, it's complicated) and the pension is $219,000 annually (ibid.), as well as many other benefits like office space, treatment at military hospitals, and Secret Service protection.