I accidentally made a racist joke at work
Oh no. How did you accidentally make a racist joke?
Because I thought it was funny.
You shouldn't tell racist jokes. Even if you think they're funny, telling jokes like that at work is most likely going to harm someone around you.
Why can't you let me have my sense of humor?
You can have a sense of humor without resorting to telling jokes that will make people feel bad or uncomfortable. Racist humor is extremely inappropriate. If you really are funny then you should be able to make people laugh without putting others down.