It completely depends on the event in question.
Weddings can range from really casual to really formal. If there is a specified dress code (semi-formal, festive informal, black tie, etc) on the invitation, it's best to abide. If they didn't specify, they can't very well get angry at you. Calling and asking for the dress code is never a bad idea if you're trying to play it safe.
As for a funeral, you're there to pay your respects. Fuck what anyone thinks about what you're wearing.
If I were running an event, and someone broke the "accepted" dress code, I really wouldn't care that much unless they were making some sort of statement. I'd care more that they showed up, because I want the person there (or I wouldn't have fucking invited them).
And yes, if you're just starting to build a wardrobe, black is generally NOT the go-to. A dark navy suit and a pair of brown shoes are the best place to start.