Comedy 101: A joke consists of a set up, and a punchline. Without a set up, the punchline means nothing: it’s just a set of words. If I think it’s normal for people to walk into stop signs, I won’t think a video of it is funny–it’s only funny because I have the context that it’s not common, that it can be funny (and that my empathy for the person doesn’t over power my willingness to laugh).
The identity of the performer matters as well. People you just met or are just getting to know better, don’t know who you are. They don’t have the full context, the full set up, for your jokes: that’s why your jokes might not make sense and why your audience may not laugh. This is also why you often aren’t able to make people laugh by just copying what you think is the comedian’s verbal set up lines, because what you don’t realize is that implicit within every joke is a play off the joke teller’s identity. If the person who walks into the stop sign is Kramer from Seinfeld, who is known for being clumsy, it’s very funny because it fits his personality. If the person is your boss, teacher, parent who you typically think of as in control and important, it may be so unexpected that you find it shocking and concerning instead of funny, or you may be afraid to laugh for fear of offense. If you’re at a comedy club, you’ll be more confident about laughing because you know it’s a joke; if you’re at a dinner party or an event with people you don’t know well, you won’t know if what they’re saying is a joke or not. You’ll be more reserved about laughing because you don’t want to be disrespectful in case they were serious. Hence why it’s harder to make jokes with strangers. Even if it’s with friends, if you don’t normally make jokes, and you don’t prepare them for it, they may not realize that you’re joking.
Finally, not everyone finds the same things funny: it might be that this group doesn’t appreciate a certain kind of joke that another group would–if a joke falls flat, look on the bright side: you’ve learned something about this group of people, which will help you to get along with them better in the future.
To improve at comedy with strangers, understand your joke better, so you can explicitly set up the context with words. However, I would advise getting to know each other better before you start making deep jokes: start with lighter ones that people from more backgrounds will appreciate, and that don’t require too much context or set up. In particular, avoid risky jokes like self-deprecation or obscenity early on.
Friends know who you are not going to judge you based on what you say when you make a joke, because they know the real you is not the temporary character you pretend to be when you make that joke. (See my post on How to Make Friends. You should avoid risky jokes like self-deprecating humor or obscene insults until step 4 of friendship, after they’ve gotten to know you with step 2 and 3, otherwise they’ll get to know you as someone who is not that great, and insulting.)