I assume you have an internet connection. If so, then go to the Apple web site. It has links to download various operating systems. (I'm sorry, I don't have the link.) Then go ahead and download whichever one you've selected. It may take up to an hour to download to your Applications folder. Your desktop should also have a window in which you start the install. At the beginning, it will ask you to select where to do the installation and you then select your attached external drive. The installer will then do the installation on that drive which can also take a long while. It will restart several times.
Before doing the download, make sure that your external drive is properly formatted by the Disk Utility app for APFS.
Then you can use the Migration Assistant app to transfer your data from the old HD to the external drive. Be sure that you have a wired connection such as a USB or ethernet cable and do not do it via wireless as that does not transfer well.
You still should look at having another external drive just for backing up everything.
I hope this answers your questions and helps you. Good luck.