Gustavo Petro defeats real estate magnate Rodolfo Hernández by a slim majority amid widespread discontent over rising inequality, inflation and violence