Updated: Dec 13, 2020
As with anything, they say learn the rules before you break them. I believe that is essentially true for anything you care to do well. When it comes to D&D it certainly helps to know the rules. It's also useful to have played more than one Table-Top RPG and learned the ins and outs of various systems. Having some breadth of understanding of various systems and their game mechanics goes a long way to breaking the rules of any one system. Being exposed to a variety of ways of thinking about the subject assists you in making judgment calls that make sense, narratively. But in the end it comes down to this: The rules are just a tool. D&D is just a game. And the game rules themselves give you, the DM carte blanche to mess with them. The DM's Guide states clearly on page four,
The D&D rules help you and the other players have a good time, but the rules aren't in charge. You're the DM, and you are in charge of the game. That said, your goal isn't to slaughter the adventurers but to create a campaign world that revolves around their actions and decisions, and to keep your players coming back for more! If you're lucky, the events of your campaign will echo in the memories of your players long after the final game session is concluded.
Everything you do needs to reveal plot, theme or character. F*ck the rules. Incidentally, you actually don't actually need to pay for a game system to form a consensus narrative. Hell I have written at least three game systems in my life. Even Gary Gygax in his book, Role Playing Mastery suggests that you do this at some point.
My actual most real advice is to use as few rules as you can get away with in the scene so as to not slow the story down. Only use rules when they become necessary. Sometimes you have to use all of them because the players have been brainwashed to expect that. Other players, who are there for the story, really don't care that much about the rules. I prefer those players. Uninterrupted role-play gives more authenticity than clever mechanics ever will. Take that from experience.
When you are using rules, you also have to have enough confidence in your judgement to sell your reasons. You have to have enough confidence in yourself to let the payers drive the rules when you can't. But really in the age of D&DBeyond... come on. This is easy stuff.
You also have to know when to let some rules lawyering slide with certain players. But you also have to put your foot down when it counts. Sometimes you have to teach them a lesson and that has to be something motivated from inside the narrative (or at least appear that way).
I am still learning rules. If you watch Mathew Coalville he will admit that no one person can know all the rules. I cut my teeth in the 1980s on the D&D Basic Set. Eventually I gravitated to White Wolfs Vampire: The Masquerade because it suits my style of play. D&D is good because loads of people play it but its hardly the greatest RPG in the world. No matter what the box says.
As a film director (evidenced by: Video Link - cogito) and as a professional actor and acting teacher, with a degree in writing and directing, I'm not really all that concerned with the getting the rules exactly right. That's trivial.
I am perhaps old enough and ugly enough to realize that this stuff is all just fluff designed to help you. They are tools. I try to get the rules correct as often as I can of course. I think I am pretty good at it. But am I going to lose sleep over it? No. I only loose sleep when my players refuses to talk to me for a week because I kill off their favorite npc. Note: Making players love your npcs is the key to making them care about your game. Being an anally retentive rules lawyer has the potential to drive them away.
I watch endless videos on D&D mechanics and I own all the (core) books and I read them. I take it seriously. But at the end of the day, I'm not going to let the rules overshadow my ability to tell a story, present ethical situations, make my players laugh or cry (and yes, my players in my personal games come to tears regularly over our collaborative story) and perform. I also go a lot further than this. I present myself as a DM with a vision and a perspective that goes beyond the standard D&D template. Beyond mainstream "kick down doors and kill orcs" or and even beyond "clever political espionage". I do those things too. I love all that stuff. But I also try to run a meaningful game. See this blog:
You have to be able to let go and trust that you still have control. A DM is not there to be a rules lawyer. A robot could do that.
What you are is a product and you need to offer something personal and different. This is where having life experience outside of the cultural matrix goes a long way.