From ifixit:

Most replacement home buttons won’t work, so check carefully before starting your repair. Your iPhone’s original home button is uniquely paired to the logic board at the factory—and without Apple’s proprietary calibration process, even a genuine replacement home button from another iPhone won’t work. To fix a broken home button, you should install a specially-made, universal-style home button. Note that these replacements only work as a button; Touch ID will not function.

If you are only replacing a broken screen, you can use this guide to carefully remove and transfer your working original home button to a new screen, preserving all functions, including Touch ID.

Why does Apple bother to do this and is it even legal with new right to repair laws?