Keeping players alert, interested, and on task is sometimes an issue especially in a group of immature or inexperienced roleplayers.
Random encounters with enemies is one way to try and keep your players focused on the table but it gets repetitive and boring after vanquishing random wandering goblin swarm #70.
Being a great speaker is a must for DM'ing even more so when the group is composed of younger players or people who are constantly joking around.
Some helpful tips for a Game Master running any RPG
Details: A GM should develop good plots and engaging encounters. It will take some time but don't slave for hours if you don't need to. Develop a system for making things easier for yourself.
Only make NPCs from scratch if they are going to be important (all major villains should be customized).
Write down what you will need so you don't have to flip through books.
Write out encounter sheets beforehand, listing the character names and the enemy so that you can write down initiative scores and get to the fight faster.
Keep it short, sweet and to the point.
Make the game for your everyone: Watch your players and find out what they like to do in a game.
Are they obsessed with magical items, or hoarding gold?
Do they prefer diplomacy or would they be happy killing all day?
Try to make your game something that your players enjoy, but spare some room for what you enjoy as well.
Try to find a balance, so that everyone gets a little bit of what they really like.
Dont be black and white: Try to make your world more than a clear-cut divide between lawful good and chaotic evil.
Add elements of all of the alignments.
Not all good people are lawful and not all evil characters go around killing everyone in sight for the hell of it.
Your players will be kept on their toes, and your world will become much more interesting for the shades of gray.
Make enemies interesting: Pick a variety of enemies, choices that will throw your players off, and surprise them.
Try to make enemy monsters as well as of characters with actual character classes.
Keep in mind the abilities of the enemies and make them into combat tactics. Take the intelligence and intent of th enemies into account. Show your players that their characters aren't the only ones who can think and strategize.
Those are some very basic tips just remember that even if you are the DM you are playing too, make it something everyone can enjoy but remember that you are in charge of the game.