You're on the right track. Usually investors see borrowing as a way to increase productivity because that's what matters' If you can artificially increase indicators, other countries and companies will use those indicators when deciding if they should branch out to that country and this creates real jobs and real revenue for the country. In other words countries don't promote themselves like companies do. They promote themselves through economic indicators and the more money they have the more they can boost those indicators. This means that by borrowing money they're borrowing to advertise in order to attract more wealth. The leaders also do it to show themselves as more capable. Voters want healthcare, strong army, jobs, modern infrastructure and the more their leaders can achieve the greater their chances for reelection.
But what’s crazy is how the world bank simply gives the money to these countries? Or maybe it isn’t as simple as I assume it is. But they give money and I don’t think it has any deadline, collateral or anything as normal loans have. It just seems that the only thing that happens is that the country will be forever indebted until they pay. Many questions arise: how do they make the money they are giving? Etc.