That would be the temperature sensing thing called a thermistor. The icemaker uses it to make decisions about when to make ice.
This particular example is from an LG refrigerator model LRSC26923TT but all the LG models are similar. Samsung’s icemaker’s use the same thermistor arrangement, too.
Usually the thermistor can be clipped right back in place as shown below:
If yours is broken for some reason, you’ll need to replace the icemaker, which you can get right here for the LG model LRSC26923TT ==> http://www.repairclinic.com/PartDetail/Ice-Maker-Assembly/1266867?modelNumber=LRSC26923TT
For other models and brands, you can look up the icemaker using your model number on the icemaker page, right here ==> http://www.repairclinic.com/Ice-Maker-Parts