In the session zero, find out what type of game your players like, combat heavy, roleplay heavy, mystery, heist, politics, etc. Let them know about any house rules and what you like as a DM. Give them an idea of how you want/expect your game to run. Give them an overview of the world and feel of the campaign that fits with what they, and you, like so they can create backstories and characters that work with the theme. I ask for a name and description of an NPC that each is friendly with, and one that they are rivals or unfriendly with. This allows me to weave these NPCs in at various points if I want and create ready hooks for side quests or sources of help/info if the players start to flounder.
I can think of tons of pieces of advice but starting out, this was by far the best advice I got and really helped me not only design a game everyone enjoys, but also it gave me so much to work as far as plot.
Session Zero has already been said. It's my number one piece of advice.
However, after you've laid out what kind of campaign you wish to run the players need to make characters. For that, my advice is to insist the characters have connections to at least one other player. Otherwise you can end up with a PC who says, "why do i want to be with you guys" some time in a future session and then the player either quits or makes a new PC or retcons his PC's past.
The alternative is what happened a few days ago at the start of a new campaign where none of the players knew each other. The dwarf druid and elf ranger already had PCs and were working on how they had a connection while the other two players were finishing their characters, a human sorcerer and a human Battlemaster.
All the PCs were in a small logging town (Threshold from the D&D world of Mystara). None were citizens of the country. It was the equivalent of New Year's Eve in the year 999. There was lots of celebrating going on, even if the dwarf and elf didn't really care about the reason. The dwarf and elf players decided their characters had gotten drunk and decided to sabotage the logging operation (save the forest!) and the other players heard this and decided they had drunkenly intervened. The constabulary decided to throw everyone in jail. The magistrate, seeing as how all the PCs were foreigners, abused his authority and ordered the hung over PCs to clear out the conveniently located dungeon nearby.
As a DM, I couldn't have been happier to see the PCs engaging with the world and each other before we even started.
Simply making sure that you're on the same page as your players with regard to what can be expected from the game (what general rating of content is allowed, what rules are used, what options are allowed, etc.) goes a long way toward heading off future problems. For example: If your game is going to have a heavy social or intrigue focus, it's better if the combat focused player knows that ahead of time so she won't get bored, or so she can make an appropriate character who can frequently participate.
Play lots of games. Play games which take very different approaches to roleplaying. Play Apocalypse World. Play The Mountain Witch and Burning Wheel, Traveller and Primetime Adventures, Fate and Call of Cthulhu. Keep an open mind.
Have a cheat sheet handy to make improvisation easier. I generally have a list of people names (by race they might run into), taverns, business names, towns and so on.
I also have one or two "extra" monster encounters sketched out appropriate for their level. These are for things that I don't think they will ever encounter but would be reasonable in the general area.
I encourage players to go off the rails, but most of the time when I'm making stuff up on the fly they still think I planned it all because when I'm "double checking my notes" I'm really just grabbing the next thing off my list and making a note of where I used it.
End the session on an exciting moment even if that means ending a little early. The players just won, the players just lost, the players are about to explore something new. Not my idea, but since I implemented it the evening's end feels much more climactic than just waiting for the yawns to call it a night.
When planning for the session, make sure you talk to your players in advance to have them state what they are doing. This way you don't have to plan for nearly infinite number of possibilities, you only need to plan for the course of action they decided to take at the end of the last session.
Allow for creative solutions for problems, but don't make things easy for the players. Without a real chance for failure, there's no sense of accomplishment.
When making up NPC's on the fly, keep track of their names and other useful information. You never know when that NPC will come up again later.
I always have one of the players give a recap of the previous session. This is an opportunity for you as the DM to fill in any information gaps that might be important. Think of it the 'Then' part of every Supernatural episode.
Sorry, this was supposed to be one. Well, just read the first item then