Colonies were economic drains if you tried to run them in a way that matched the stated ideals of the colonial powers. If you were doing a pure exploitation, then some of them could pay for themselves.
I would say that to get colonialism lasting until present day in any significant form you would need to go back to at least the 1880s and prevent the scramble for Africa as such. If you have Africa colonized when it was economically beneficial to do so and ignored when it wasn't then you don't end up up with a lot of colonies that weren't worth having there. Of course you also have a whole lot of bad things happening in areas outside of European control, as European weapons got traded into the interior and the early adopters got to use repeating rifles against opponents at the spearchucker or musket level of military tech.
And what happens in Africa still doesn't do anything to prevent the independence of India or Indonesia. The problem, especially in India was partly that the British said a bunch of things to justify their empire that were total BS, and then gradually started believing them and trying to live up to them. At that point, yeah the empire cost more than it was worth.