Why? Why was Jesus tempted in every way possible? Well, if we look back in Hebrews 4:15, the first part of it says, "For we do not have a high priest who is unable to sympathize with our weaknesses," This is saying that because Jesus was tempted in every way we have been, then He can understand what we're going through, and also so that we can't have an excuse for sinning.
1 Corinthians 10:13 says, "No temptation has overtaken you that is not common to man. God is faithful and will not let you be tempted beyond your ability, but with the temptation He will also provide a way of escape, that you may be able to endure it." This verse can be proven by the fact that Jesus, as a human being, was tempted in every way but always found a way of escape because God never gave any man more than he can handle. Yes, Jesus did have the capability to be perfect as we see in 1 Peter 2:22 and man does not as we read in Romans 3:23. But we always have a way of escape. There has never been a perfect being on this earth besides Jesus. But that is exactly why Jesus died on the cross.
So next time you think that no one understands, or that no one has gone through what you have, remember Hebrews 4:15 and that Jesus was also tempted but without sin.