Once upon a time, a sixteenth century English dude decided that it was low-class and vulgar to end a sentence with a preposition. So, ever since then, we've been trying to tuck our prepositions inside of our sentences so that we can be proper. It's important to know that it is grammatically incorrect to end a sentence with a preposition. However, I come from writer's workshops where I teach grammar classes. We advocate for ending a sentence in a preposition if it would help you avoid creating a really awkward or overly stuffy sounding sentence.
Let me give you an example. So, in this case, we have two sentences that mean the same thing. One sounds very formal, and one sounds informal, and it's all because of where the preposition lands. To whom did you address the letter? Well, this is the grammatically correct way to phrase this sentence. You'll see that the preposition to, comes at the beginning of the sentence, not the end. Another way to phrase it is whom did you address the letter to. In this case, our preposition to comes at the end, and technically it's incorrect, but it does sound a little less formal.
There are instances when obeying the rule about prepositions can create a truly disastrous sentence. And Winston Churchill brilliantly illustrated that with a joke. He said that is the sort of English up with which I will not put. Well, you can see that our preposition up comes in the middle of the sentence. So, technically it's correct, but it's a truly awful and awkward sentence. So, in this case, it would definitely sound a lot better to put the preposition at the end and say that is the sort of English I won't put up with. I hope that answers your question about whether or not you can end a sentence with a preposition.