The UN has adopted a landmark treaty prohibiting nuclear weapons, described as "a historic event for humanity".