House Republicans are poised to eke out a majority after a poorer-than-expected showing, but their leader is no lock for speaker—and he may have trouble holding on if he gets it.