Two distinct functions that you want to do, OBD2 Code reading and Programming options are depending on how much you want to spend and if you want a handheld unit or a laptop based software system.
Creator +310 OBD2 Reader seems popular with members on here for code reading and code clearing, viewing of some live data also possible.
Really cheap option is an ELM327 OBD2 interface used in either wifi or bluetooth options and linked to your phone using an App such as Torque that can be downloaded from the usual App stores. It will read and clear codes except airbag codes and will view live data.
ELM327 in either format from ebay.
If you want to go in via a Laptop then BMW INPA software is ideal for all BMW models either downloaded for free from a trusted site or purchased from one of the ebay sellers, software sent on a Stick these days as opposed to a CD. INPA can be problematic when it comes to setting it up on a laptop but once installed it is very good. An alternative is BMW Scanner 1.4 which when installed will read all modules fitted to the car and code read and allow limited coding functions, I use this on my Z3 and Z4 with good results.
A lot of people use Carley for code reading and coding functions with success however this is at a cost and an ongoing subscription to operate it.
Lots of old posts on here regarding code reading options if you have a search.