The billionaire founder of social network Facebook Inc. has agreed to give the majority of his wealth to charity, part of a broader group of rich entrepreneurs committing to philanthropy earlier in their lives.

Mark...