One of the big things I don’t see mentioned here is that while the “active ingredient” in the medication is the same, all the other stuff in it is not. This also includes the binding agents that hold the med together and also the release mechanisms that control how/when the medicine is absorbed into your body.
For example, generic extended release amphetamine salts don’t release into your body in the same way Adderall XR does, despite being the same medication. While the patent on the drug has expired, the patent on the proprietary release mechanism has not expired. So generics can’t copy it. This could cause the generic to not work as well for some people, or some people could have a reaction to those different ingredients.
Edited: fixed spelling
I just want to jump in to say this is probably dependant on where you live or which pharmacy you go to. In my state, if the doctor writes for the brand name, the pharmacy MUST fill the brand name. They can call the doctor to get approval for the generic, but they won’t just fill the generic at the patient’s request. YMMV