Why is the dative form of a word used in a location sentence like "Er ist in einem Laden" "He is at a shop" And what similar situation is it used in
Most European languages know a number of different cases for substantives. Latin and ancient Greek already had that feature, Latin even had five cases, one more than German. Russian has six.
The different cases (nominative, genitive, dative, accusative in German) are basically used to add information to words in a sentence about what role they play in the sentence. It's hard to generalize what role a certain case stands for though -- for direct objects, it depends on the verb, for prepositional objects, it depends on the preposition.
- Subjects and objects without prepositions
You can think of a verb as some kind of hub module, it has different ports where subjects and objects in different cases can dock, and depending on where they dock, they have a certain meaning in relation to the verb. Excuse the technical and maybe somewhat skewed metaphor, I'm not a linguist.
geben (to give)
has (at least) three "ports": one for a subject in nominative, one for an accusative object and one for a dative object, which, respectively, stand for who is giving, what is given and who it is given to.
anklagen (to accuse)
has "ports" for a subject in nominative (who accuses), one for an accusative object (who is accused) and one for a genitive object (accused of what).
What case is used for what purpose? There are rules of thumb, but in the end, it just depends on the verb they're with, and these rules just have formed over centuries, so there is no serious way to answer the question why a certain case is used in a certain meaning with a certain verb.
In English, the different cases have withered away with the centuries and their place has been taken by prepositional objects: for "to give", the dative object has become "to ...", for "to accuse", the genitive object has become "of ...".
- Use of cases with prepositions
For prepositional objects in German, most prepositions always stand with one specific case -- but for some of them, different cases are used to give the preposition a different meaning. This means the German language (in theory) needs fewer prepositions, as the same preposition can be used for different purposes, and the meaning is still clear because of the case it stands with. (It also makes it harder for German learners, because you have to know the declensions to be able to identify the case)
For example, there is one preposition "in" in German that can mean "in" or "into" in English, dependent on which case they stand with. With dative, it's "in", with accusative, it's "into".
Er ist in einem Laden (dative). (He's in a shop.)
Er fährt in eine Straße (accusative). (He drives into a street.)
The rule of thumb for many of these prepositions (like in, über, unter, auf, an ...) is that dative denotes a location while accusative denotes a direction. Why? I don't know, this rule is basically a few thousand years old. Latin already had "in" with two different cases - ablative for location and accusative for direction. German doesn't have the ablative, it uses dative instead. Ancient Greek had the dative, but it died out at some point, together with the version of "in" that stood with dative (εν).