"Beyond me" means "beyond my comprehension" -- ie, I cannot understand it at all.
"It" refers to "the fact that you and Tom can be roommates." If you'd like, you can reverse the order of the clauses so as to eliminate "it:"
How you and Tom can be roommates is beyond me.
You could also replace "how" with "the fact that -- the meaning would be quite similar:"
The fact that you and Tom can be roommates is beyond me.