Fast radio bursts (FRBs) are bright flashes observed typically at GHz frequencies with millisecond duration, whose origin is likely extragalactic. Their nature remains mysterious, motivating searches for counterparts at other wavelengths. FRB 121102 is so far the only source known to repeatedly emit FRBs and is associated with a host galaxy at redshift $z simeq 0.193$. We conducted simultaneous observations of FRB 121102 with the Arecibo and MAGIC telescopes during several epochs in 2016--2017. This allowed searches for millisecond-timescale burst emission in very-high-energy (VHE) gamma rays as well as the optical band. While a total of five FRBs were detected during these observations, no VHE emission was detected, neither of a persistent nature nor burst-like associated with the FRBs. The average integral flux upper limits above 100 GeV at 95% confidence level are $6.6 times 10^{-12}~mathrm{photons cm^{-2} s^{-1}}$ (corresponding to luminosity $L_{rm VHE} lesssim 10^{45}~mathrm{erg s^{-1}}$) over the entire observation period, and $1.2 times 10^{-7}~ mathrm{photons cm^{-2} s^{-1}}$ ($L_{rm VHE} lesssim 10^{49}~mathrm{erg s^{-1}}$) over the total duration of the five FRBs. We constrain the optical U-band flux to be below 8.6 mJy at 5-$sigma$ level for 1-ms intervals around the FRB arrival times. A bright burst with U-band flux $29~mathrm{mJy}$ and duration $sim 12$ ms was detected 4.3 s before the arrival of one FRB. However, the probability of spuriously detecting such a signal within the sampled time space is 1.5% (2.2 $sigma$, post-trial), i.e. consistent with the expected background. We discuss the implications of the obtained upper limits for constraining FRB models.