Everyone in the game is there to play a game
This is supposed to be an entertainment activity. Everyone is supposed to be having fun. That is the point of a game, after all. That includes player 1, player 2, and you.
As Southpaw Hare mentions in his answer, the same page tool is an excellent way to try to help everyone get “on the same page” so it is possible for everyone to have fun at the same time. Note that it doesn’t always work, though—sometimes people cannot all be on the same page, and thus it won’t be possible for everyone to have fun at the same time. That happens, and that’s OK. It sounds like the first player already came to this conclusion, and yeah, that’s OK. Maybe he’s wrong, maybe there were ways you could get on the same page—but if it were me, I wouldn’t expect it (more on that in a bit).
So in answer to your title question, a “player telling a DM what he can or cannot do” is... abrasive and obnoxious, but his position is not completely unreasonable (though it is at least somewhat unreasonable, no matter how much benefit of the doubt we give him). No player is allowed to stop a DM from having fun, but no player is required to play even if the DM is making it unfun for them. What the player presumably means is “you cannot do that or else I won’t want to play.” There are vastly superior times and ways to discuss that kind of issue with a DM than this player is using, but that doesn’t automatically invalidate his position—just his approach (and again, more on this later).
Tone and player #1
Tone is extremely important to the game. Many, many tables play a laid-back, “beer and pretzels” kind of game where absurd behavior is welcomed, even the point of the game. Many, many tables have a serious, dramatic kind of game where immersion is the utmost concern and people stay as thoroughly in-character as possible. And many, many tables are somewhere in between, or another option altogether.
This is the kind of thing you have to get on the same page about. And you need buy-in from the players; you will never be able to mandate appropriate tone. You and the players both need to agree about the kind of tone you’re talking about, and both you and them have to match your expectations to these.
But it is also acceptable to have hard limits you will not budge on. This may present the kind of situation where the table cannot get on the same page and thus cannot play together, but ultimately, that’s reality. For me, the predatory sexual comment about a minor would be over the line—way, way over the line. I’ll stipulate that it was meant to be humorous and not meant to actually sexualize a minor or advocate predatory sexual behavior towards anyone, but the mere fact that they consider these humorous topics would give me a lot of hesitation. It would make me very unsure that this was someone I could ever get on the same page with. I might try, give the player #1 an opportunity to apologize, but I would be dubious.
In short, I think the player was right to leave, seeing as you are aiming for a more serious game, and I think you are better off without that player in the game.
Rules-lawyering and player #2
This is another topic worth getting on the same page about; everyone has different relationships with the rules, and holding strictly to them or not doing so is very important to many people’s enjoyment of the game. The problem with interruptions is a problem no matter how anyone feels, because it grinds the game to a halt. But the interrupting player would no doubt agree with this—he would just argue that he shouldn’t “have to” do so as often as he does, because you “should” stick closer to the rules.
Player #2 is wrong. There is no imperative demanding you stick closer to the rules, and there definitely isn’t any imperative for him to call you on not doing so. You definitely should not continue to play with this person until you have cleared that particular issue up.
However, player #2 is not “wrong” for wanting a game that sticks closer to the rules. He’s not “right” either. It’s just a preference—a preference that you two don’t share. Even just making this explicitly clear before the game can help with this kind of problem. If a player knows that he or she has to temper their expectations because not everyone shares their preferences, they are far less likely to be upset by it, far less likely to interrupt. You might think that this should go without saying, but that is not really any more fair than him assuming that it should go without saying that the rules will be followed.
Getting on the same page helps with this kind of thing. Getting on the same page also helps figure out where the limits are—what kinds of things are going to prevent someone from enjoying themselves, preventing that group from playing together. Your limits may not overlap with his—at which point you know that the two of you cannot play together. You are not obligated to offer a game he will enjoy. But he is also not obligated to play in a game he won’t enjoy. If you cannot compromise where you can both enjoy the game, then he’ll have to choose to not play. The rest of the group can decide for themselves if they want to play anyway.
Articulating your own limits is also valuable. For example, his point about adding NPCs to a party of 6? I’m personally totally on board with that. I recently decided to quit a game after the DM just could not say no to more players and we had a party of 8 bogging the game down. It just got to be exceedingly boring with how long everything took, so I left the game. We had a neat little exit scene for my character, we spoke about hopefully getting together for another game some other time, and that was it. If it had been a party of 6, I might have been fine—but if the DM added NPCs to the group that caused it to slow down like it did with 8 PCs, then maybe I would have left because of that.
Do you need to have NPCs in the party? I don’t know, maybe you do. You don’t have to budge on that, and he has no right to demand that you do. But I can’t really see why that would be make-or-break for you, while I can see why it would be make-or-break for him. Getting on the same page allows you to discuss that, and agree with things.
So get on the same page, find out if you can play together, and if you can, make it clear that you are now supposed to be on the same page, that you have both agreed (presumably) to some kind of compromise (even if that’s just you putting your foot down), and that the interruptions need to stop. If you need to re-visit getting on the same page, if either of you finds that your previous compromise isn’t working out (neither of you is required to continue to do something you don’t enjoy just because you agreed to a compromise), that needs to take place outside the game, before, after, or between sessions.