The literal meaning of the Auxiliary verb {限|かぎ}る is 「境を付ける」 'to set a boundary'. This means that に marks the location (or situation), within which the speaker then states as being 'the boundary'.
(...) とは限らない
means that it doesn't always hold that (...); it isn't always the case that (...): something isn't necessarily always true (when drawing conclusions).
It comes from Quotation + 限る, in that "it is not limited to (...)"
Often goes hand in hand with the て-form + も, giving the nuance of "not even when (...)".
日が出っても暖かいとは限らない。 Even if the sun is out, it isn't necessarily the case that it is warm.
日本に2年間住んでいるからと言って、日本語を話せるとは限らない。 Saying that a person has lived in japan for 2 years, it doesn't always hold that they can speak Japanese.
For形容動詞+ , it turns into でも. It also needs to have a だ in front.
田舎でも静かだとは限らない。 even if a place is rural, it doesn't necessarily mean that it is tranquil.
https://bunpro.jp/grammar_points/とは限らない
(...) is the best
other meaning of に限る. Which one it is depends on context. means that there is nothing better than (...), it is the best thing. from に. note that this takes precedence over the typical meaning of "it is limited to (...)"
暑い日は冷たいシャワーを浴びるに限る There is nothing better than taking a cold shower on a hot day.
休みの日には仕事をしないに限る There is nothing better than not doing any work on a day off.
家具を買うなら、このお店に限る。 If you are buying furniture, there is nothing better than this store.
https://bunpro.jp/grammar_points/に限る
Exclusive to (...)
other meaning of に限る. Which one it is depends on context. Denotes that something is limited to (...)
この施設を利用できるのはこのアパートの住民に限る。 The ones who are able to used this facility is limited to those living in this appartement complex.
アルバイト募集中。ただし、英語ができる人に限る。 Looking for part timers. But, limited to people who can speak English.