A defining clause is necessary to identify the person or thing you are talking about. For example:
"Madam, can you tell us which of these five men stole your handbag?"
"Yes, officer. It's the man who is scratching his left ear."
The relative clause "who is scratching his left ear" is important: without this information, the man cannot be identified. Notice that a defining relative clause has no commas before or after it.
A non-defining relative clause adds extra information, but we could omit this information because it isn't necessary to identify the person or thing. For example:
Queen Victoria, who was once famously "not amused", reigned for 63 years.
The relative clause "who was once famously 'not amused'" can be left out; it adds some interesting extra information, but isn't needed to help us identify Queen Victoria. Notice that a non-defining relative clause is surrounded by commas.
In both these sentences, the relative pronoun is the subject of the relative clause. Here are some where the pronoun is the object:
See this photo? Ellen is the girl whom Peter is hugging.
This table, which I bought only yesterday, is useless.
Notice the word order of these relative clauses: relative pronoun -> subject -> verb. This is different from when the pronoun is the subject: then it's relative pronoun -> verb -> object.
We can omit the relative pronoun when, and only when:
1. the clause is a defining relative clause, and
2. the relative pronoun is the subject.
Of my four examples, the only one where the relative pronoun can be omitted is:
Ellen is the girl Peter is hugging.