My jokes often used to fail.......I think it was the mind-blindness, i.e. if it was funny to me then I'd automatically think they'd like it too. But a lot of my humour was quite dark and sardonic, and you have to pick your audience with that kind of stuff. Most people don't seem to like it. Also it took me a long time to realise that humour is usually quite simple, e.g. just using a funny word is often all it takes.....I was always trying to be way too clever, and would just become obscure and lose my audience.
I've noticed other people's jokes don't always hit the spot.....best thing to do is grin at them and say "what are you on about?" - thus filling the icy vacuum created by the failed gag. Sometimes failing to pick up on the warm overture of a joke is a signal that the joker isn't accepted.....if somebody doesn't like you then your jokes won't amuse them so easily, and they will be more ready to take offense.
I've often felt the same fear as Joe90 about those little "put-down" jokes......teasing can be quite dangerous.....even when the "insult" is impossibly far-fetched, I've known people look offended. Though I've got away with it a lot too. I think it's important to keep trying. It's a force for good in friendships when it works (reassures people that it's OK to step out of the ultra-polite zone, maybe lays the ground for criticism without tears, brings people closer together). If you get it wrong, you can always apologise. I often add "just kidding" to the end of it, or "I don't mean it....your nose isn't really big" if I'm in any doubt about the way it's going down. I remember being in a conversation with somebody where we were both ribbing each other for ages, it was fun, and neither of us were at all offended. But I don't take that kind of risk lightly, and even at the time I was wondering how safe my comments were. Also I knew a guy who had such a session with his partner, and he said it was good at first but then some of the digs got too personal, and it turned into a serious blazing row.