There may be some small difference in meaning, but I think this is best learned over time by hearing these phrases in different contexts. If you are a beginner in English, you can say either phrase and native English speakers will understand you. And that is the point of communication.
However, to give you two examples, you might use one sentence to answer a question, depending on how the question is phrased:
What would you like to have?
-I would like to have something to eat.
What would you like?
I would like something to eat.
But, actually, a native speaker would understand you, no matter which answer you gave. One answer might sound more natural, but it is hard to teach "What is natural?" by rules. It is best learned over time by hearing how native speakers use such expressions in context. Because, in fact, you will forget any rules a teacher gives you. But you won't forget observations that you yourself make.