I do the same quite often by running the following commands: ggVGy.
The first command, gg, jumps to the beginning of the file. Then we select the entire first line with V. Still in visual mode, we jump to the end of the file with G, before copying (yanking) everything with y.
You can make this even faster and easier by mapping all of these commands to one key. With the mapping below, pressing the leader key and X will copy the entire file.
nnoremap <leader>X ggVGy
If you need the content to be available to the system clipboard, and not only in Vim, you should use "+y instead of y. This will yank to the "+ register used for the system clipboard. You can find more information on this topic in this question.