A dungeon masters job is to weave an epic tale where the players are the heroes.
A dungeon masters job is NOT to smash the heroes into giblets. Bad luck, bad rolls and traps will occasionally cause failures and deaths, but if you measure your success in trashed character sheets you will soon not have a campaign because you won't have any players.
A DM has to be several things. An actor, a director, a writer, an architect and a bit of an artist as well. In detail you need to act out NPCs, coordinate the action, create a plot, design a world and bring it all to life. If that seems daunting to you on the first go, there's no shame in buying a packaged adventure or two to help you get a feel for the experience.
Be cautious how you hand out loot. It's better to be conservative with the loot than overly liberal. Of course, you don't want to be too tight-fisted. You should allow players to gain loot at a pace that's proper with the difficulty of your campaign. Don't fret if you screw up. But watch out that they don't get too strong to quickly. A party that commands a personal legion of paladins, has jewel encrusted armor of invincibility for each, possess 5 or 6 staves of blow up the moon and rides into battle on the back of an ancient silver dragon is probably too strong and is never going to feel challenged, especially if it's a party of level 8s and they're target is a hobgoblin raiding camp.
When running villains, especially intelligent ones, remember not to think like an AI. Even wounded wolves know better than to fight to the death, though rabid wolves and other crazed or mindless creatures will certainly not yield because of fear. A scheming dark wizard will probably be very prepared, will have a plan B, and will have plenty of options for a quick withdrawl. Although his Ogre henchmen will probably just "Hulk Smash". In a sense, the villains are your characters, you make them play to their strengths.
Most important is to have fun. If no one's having fun, then what's the point. Also D&D does have rules, but sometimes the rules can be slightly bent for the sake of pacing or something else, but try not to be an ass about it. If you fudge a die roll by 1 to make a miss into a hit because it advances the story better, that's fine. But if your villain rolls a 1 and you decided to announce he crits the healer and runs her through, then you're being a dick.
Good luck and Rally-Ho.