Set textwidth to 80 (:set textwidth=80), move to the start of the file (can be done with Ctrl–Home or gg), and type gqG.
gqG formats the text starting from the current position and to the end of the file. It will automatically join consecutive lines when possible. You can place a blank line between two lines if you don’t want those two to be joined together.