The Division 2 gives you XP for everything you do and it is absolutely necessary to level up, gain new skills and unlock new areas, but if you do not know how to you may end up going through the grind and that could end up getting you stuck in the same level for a long time. But there is a way that you can do to earn XP quickly.
How to level up fast in Division 2
You will need to unlock the Accolades perk and 5 SHD tech points for this, this, in turn, will increase the amount of XP you would normally get.
The most XP in the game is gained by completing the main missions and side SHD missions. If you think you can pull off a higher level mission without meeting the level required then you will earn far more XP than you would otherwise.
After you are done with the main story and the side missions, you can free roam in the open world and take down enemies which will keep giving you XP.
The Accolade perk will help you greatly in leveling up which will unlock further perks and skills which will help you along the way.