The House passed legislation Wednesday that opens a pathway for some undocumented immigrants to obtain driver's licenses in Massachusetts, a move advocates say would make roads safer for all motorists and opponents argue rewards people for entering the country illegally.