1. It can give you happiness when you give happiness to others.

(What does 'it' refer to in this sentence? What functions does 'it' have?")

2. Volunteer work is not something that you must do.

3. Volunteer work is not anything that you must do.

(Are both correct? What is the difference between Sentence 2 and Sentence 3?)

1. "It" in this case is the act of giving. The sentence is rather awkward.

"Giving happiness to others can bring happiness to you" sounds better.

2. and 3. are both correct. "Anything" refers to one type of thing and "Something" refers to a plural class of things. "Volunteer Work" can include various types of activities, but can also be thought of as single way to spend one's time. Option 3, to me, sounds more negative about the advisability or necessity of doing that type of work. Number three sounds like volunteer work should specifically be avoided.