Encounters are arguably the cheese of any campaign if the PC's are the meat and the DM is the Taco Shell. I won't go into the mechanics of building encounters because there are plenty of YouTube guides for it and the DMG goes over everthing you need to know. What I'm going to go over here is the importance of WHEN to add encounters, how many you should add, and the content of such encounters. This is for those beginner DM's who don't really get how encounters influence the feeling of a game or how it really impacts the characters or a campaigns pacing.
First of all if you're running a pre-made campaign and it has some sort of list of encounters to have during travel or whatnot I urge you to carefully look over the list and consider your situation. Say, for instance, I have the list of day and night encounters for the Curse of Strahd module for D&D 5e. Almost all of the monsters are either weak as shit for the scaling of the campaign or they're just... boring and inconsequential. At this point I've completely abandoned even thinking of using it because it adds nothing to the campaign itself and just slows eeeeeverything down.
So, instead of that, I've began building my own encounters using different monsters straight from the Monster Manual that I deem thematically accurate to the campaign setting. That, and I've been spacing out the encounters way more and making sure they just don't feel shoehorned in for the sake of having combat. In a different perspective, not all of the encounters have been combat in the first place, that's why they're called "encounters" and not just "combat". At one point I had the party stopped at a crossroads and straight up encountered a Bride of Strahd who had come to give them a message instead of using Strahd himself. Long story short, it can add a lot to a campaign if you try to be more strategic in the amount of combat encounters you have vs. roleplaying encounters.
The short of it is this: don't force your encounters if you don't need to, and don't make them all random combats. Space them out, plan them accordingly, and add flavor where necessary. Make them actual parts of your world and story rather than just filler because RPG.
That's all I really have to say. It's not much I know, but it's not really a subject that really needs a lot of explanation. Till next time.