A preposition can never be used on its own. It must always be used with another word. In most cases, a preposition is placed before a noun or pronoun.
A phrase is a group of two or more words that does not contain a subject and a verb working together. There are many types of phrases, including verb phrases, adverb phrases, and adjective phrases.
So, because there’s movement from one place to another, the accusative case das Bett has to be used after the dual case preposition unter. In the second sentence the shoes are already under the bed.
Though ending a sentence with a preposition can often sound clunky, it's still acceptable to do so and sometimes can help make its meaning more clear.