Raw trial and error. You have to accidentally piss off a lot of people, and cause a lot of uncomfortable moments, like ones with deep silences, until you become funny. A lot of people have childhood embarrassment memories from times the tried to be funny and it just fell flat.
Don't try too hard, don't overthink it. If you cannot make a joke work, shelve it and maybe you can rework it into something humorous later. Delivery can matter more than content (or perhaps personality/likeability?). Look at Norm MacDonald. He could get laughs with a single word and a glance.
What makes you fit in your spot (zone), you can do good jokes at. Find out what makes people laugh within their boundaries [many don't like a off-topic joke for an example], and what you can do with the info.
Don't go sperging out the jokes though with random humor