The ALPINE-ALMA [CII] survey. The nature, luminosity function, and star formation history of dusty galaxies up to z≃6