如果有介词,代表此句的先行词是一个时间段或者一个处所,方位,而定语从句一般是修饰名词性成分的,所以需要用一个介词来与连词搭配,来与这个状语成份匹配:
I'll never forget the years in which I were with him. 我永远不会忘记和他在一起的岁月
in the years 在那些年
He broke the shelf on which we had a lot of fun. 他把那个架子弄坏了,我们曾在那个架子上玩得很开心
on the shelf 在架子上