Hydrochloride salts are made to simplify purification. In what way does it simplify purification? Also, I don't quite understand how the HCl is associated with the main methylphenidate section; how or if it's attracted in anyway.
By changing it from the non-charged species, which would likely have low water solubility, to the charged salt, which has much higher water solubility. If you look at the structure of methyl phenidate, you’ll see a nitrogen contained in the form of an amine. It has a lone pair of electrons, which it can use to attack electrophilic species. If you put it into a solution of HCl, it will form a bond to the H+
, giving the nitrogen a +1 charge. That is balanced out by the Cl-
counter ion to give the HCl salt.