Is it okay to mention family background in SOP? I'm applying for MS in Mathematics. My grandfather was Math professor and my uncle is also Math professor. Such family background was one of my reasons to  study Mathematics and I was wondering if I can mention my family background briefly at introduction in SOP?
Can you? Sure, it's not wildly inappropriate.

Do I recommend it? No! This is a 1-2 page document where you state what your purpose is (hence the name). It's not a time to talk about your childhood, why you were inspired to study math, or what your favorite type of helicopter is. It's where you talk about what you've done so far and what you want to do next. 

You may have to talk about your personal situation -- usually to explain a bad semester, etc. And it's fine to state a few interesting details about yourself (especially if you have significant achievements outside of math, or a non-traditional background, etc.). But listing the professions of your family members is neither necessary nor interesting.