The fastest way to level up in Pokemon Go is to fight 5 tier raids
Completing a legendary Pokemon raid can give you 10,000 XP per battle, and with additional bonuses such as using the Lucky Egg and events, you can sometimes get as much as 40,000 XP per raid.
If fighting in 5 tier raids is not an option, I'd reccomend hatching eggs. 10 Km eggs can give a minimum of 1000 XP.
From personal experience, I found adding lots of friends and sending gifts daily was very good for grinding XP. As friendship level with different users increase, you can get anywhere between 3,000 XP to 400,000 XP.
Source:
https://www.eurogamer.net/articles/2018-07-05-pokemon-go-xp-chart-sources-fast-xp-pidgey-farming