I shared something with my coworker, because I didn't know who else to talk to.
What did you share with them?
I told them about how my wife is mad at me.
It is sometimes ok to talk to close friends about your marriage problems in order to get advice, but it is a bad idea to tell your coworkers things like that. You should keep your work relationships professional.
I didn't tell my boss. He can't know what I'm doing at home.
It's good that you didn't tell your boss, but I still don't think you should have involved your coworker. It's generally better to keep your work relationships and your personal relationships separate.