Deciphering dream is a complex task. Till now scientists are argumenting on the purpose of dreams. Everyone dreams sometimes one remembers and sometimes not. Dreams give us enormous possibilities of a particular situation. It sometimes is a reflection of certain recent thinking that we have in our brain.
Sometimes we face some particular situation when we realise that we already dreamt of. This may be just 7-10 second or less. While experiencing this in real time you freeze and mind starts relating to a dream that was experienced years ago. So question is " Did we saw our future before it happened?"
If you search online they give many answer. The Bottomline is that "brain is very complex".
Coming to "How it can give solution to our problems?"
We must understand there is never a single solution. There are multiple solutions and some are best in terms of the situation. During sleep the body performs minimal activities. Hence vast potential of the brain remain unutilized at this period which can be used to have multiple simulation of the situation to arrive to the best solution.
The procedure to reach this phase may be tricky.