Often terrorists can gain a foothold in a country because of internal strife - like in Afghanistan and Mali. Why is there internal strife? Well here's my opinion, which may be fair or may be a load of pineapples.
I think it's because generations ago governments like ours ( and French, Belgian, German, Dutch etc etc) drew up arbitrary, convenient boundaries which split tribal homelands and created ethnic imbalances. Those imbalances led to situations where a majority of people may be ruled by a minority of different origin, a definite cause of discontent - they shouldn't be in the same country. (Like hutu's and tutsi's, Serbs and Croatians, Muslims and Hindus, Kurds in Iraq etc). As soon as a chance emerges they are at war with each other, settling old scores. We started it, to expand the empire i.e. for profit. And where did that wealth go to? Well to better the lives of the Victorian working class of course - I don't think.
Our glorious past is in reality a shameful past. I don't agree with terrorism (obviously) and I applaud any moves made to assist and stabilise countries where possible, but let's just remember that when the 'sun never set on the British Empire', it wasn't necessarily good for those in the colonies, or for vast majority in the UK either. The legacy of stately homes and gardens that we all love to visit, including myself, are really built upon foundations of slavery and forced exploitation of poor people from around the world.
end of pineapples.
K