Transferring the H1B to a different company is straightforward. However (and this happened to me) if the original company is sponsoring your green card, you will have to restart the green card application process with your new employer (unless you are in the final stage of the process). Bear in mind that the green card process can take several years. IMO this is an unacceptably high risk.