All dependencies installed by apt-get -f install can only be installed from your software sources, so if any of your software sources are unsafe then sudo apt-get -f install is unsafe too. In the case of a vanilla Ubuntu installation where only the default Ubuntu repositories are enabled, then sudo apt-get -f install would be safe, but since packages from the default Ubuntu repositories don't conflict with each other a suggestion in the terminal to run this command ordinarily wouldn't appear in the terminal.

To let apt automatically configure dependencies, open the terminal, change directories with cd to the directory the contains virtualbox-6.1_6.1.16-140961~Ubuntu~eoan_amd64.deb, and run the following command

sudo apt install ./virtualbox-6.1_6.1.16-140961~Ubuntu~eoan_amd64.deb

instead of using dpkg -i. Then you won't have to run sudo apt -f install afterwards. A command of the form sudo apt install ./package-name.deb automatically installs all the dependency packages that are required to install the .deb package. It also installs the recommended packages by default, but apt has an option to disable installing recommended packages for an individual command. It should also be noted that the current working directory in the terminal should be the same directory that contains package-name.deb, so that apt can find package-name.deb in the current working directory.