It's a good idea to have backups of your important files before upgrading to Windows 10.
To upgrade, reboot your computer and choose the Windows option in its bootloader. From within Windows, download the Media Creation Tool from Microsoft, launch it, and select "Upgrade this PC". Perform the same upgrade process you would to upgrade any Windows 7 or 8.1 PC to Windows 10.
You could also download the Windows 10 ISO from within Ubuntu and burn it to a disk. You could then reboot into Windows 7 or 8.1 and launch the setup program from the disc. Be sure to upgrade by running the installer from within Windows 10 and selecting upgrade. You can’t actually perform a clean install of Windows 10 on a PC until you first upgrade it. The upgrade process effectively grants your PC the free Windows 10 license. Microsoft makes a note that your PC's specific hardware configuration is allowed to use Windows 10 on its activation servers.

Go through the typical process to upgrade Windows as if it were the only operating system on your PC. When the installer reboots normally, you'll be brought back to the GRUB2 bootloader menu again. Select the "Windows" option here each time your computer reboots.

Windows 10 will install normally, replacing your existing Windows 7 or 8.1 system with Windows 10. It'll work just like it would on a typical PC with only Windows 7 or 8.1 installed. As it's an upgrade, you won't be prompted for partitioning or anything along those lines. Windows 10 will just replace your existing Windows 7 or 8.1 system on the existing partitions, leaving your Ubuntu partitions alone.

What about the GRUB2 bootloader?
Typically, installing or upgrading Windows will overwrite your Ubuntu bootloader. Ubuntu will become inaccessible until you reinstall Linux or perform a repair-install of GRUB2. Every time you boot your computer, Windows will just boot immediately. That's why you should typically install Windows before Ubuntu when setting up a dual boot system.
But, surprisingly enough, the Windows 10 upgrade process won't overwrite the GRUB2 bootloader on Ubuntu. Everything will continue working normally, and you'll see the usual Linux boot loader every time your reboot your PC. After you perform the upgrade process, selecting the "Windows" option in the bootloader will boot into Windows 10 instead of your old Windows system.
Optional: Update your GRUB2 boot menu
Everything will "just work", but Ubuntu won't automatically change the operating system label in GRUB. It will continue to either say "Windows 7" or "Windows 8", even though that option will boot you into Windows 10.
You can ignore this option entirely and continue using it — everything will just work. If you do want to rename the Windows 7 or Windows 8 entry so it reads Windows 10 instead, you’ll need to edit your GRUB2 boot menu.
In Ubuntu, you can install the Grub-Customizer tool from this PPA and use the graphical interface to rename the boot entry. You can also use this tool to make Windows 10 your default operating system that starts every time you boot your PC if you like.

The convenient upgrade process doesn't tamper with your system and overwrite the Linux bootloader, which is a nice change from previous editions of Windows, but if you want to install Windows 10 from scratch in the future, you should still install Windows 10 first and Ubuntu afterwards. Performing a clean install of Windows 10 would overwrite your Ubuntu bootloader with the Windows bootloader.
In the future, you can clean install Windows 10 on the same PC after it's been upgraded once. Microsoft will remember that the particular computer and its hardware are eligible for the free Windows 10 offer and are properly licensed. Just go through the installer and click the skip option each time you're asked for a product key. Windows 10 will automatically activate itself online with Microsoft after you reach the desktop.
Source: Upgrade an Ubuntu dual boot to Windows 10