What is this thing on my garage wall?
Transformer. Probably for doorbell, possibly for hard-wired controls for garage door opener.  The "string" is fabric-insulated low-voltage wire, which was commonly used for that purpose.