The core sense of fi is containment or situatedness: something lies within a place, period or relevant conceptual setting.
«في: للظرفية»
Fi expresses containment or being within a context.
“Al-kitab fi al-sunduq” — the book is in the box. This is straightforward spatial containment. Legal language can also place an event “within” a time, or relate it to a verbal noun or action.