Patents can only be issued for new and non-obvious inventions. While these requirements seem similar, they are two distinct tests. Each requirement requires the examiner to compare the claims in the patent application to the prior art. Prior art consists of anything that is publicly available, such as patents, research papers, or products on sale.
Novelty requires that your exact invention not already exist. A claim will be rejected for lacking novelty if the examiner finds a single piece of prior art that demonstrates each and every element of a claim in the patent application. If you can show that your invention is even slightly different than the cited prior art, then you can typically overcome a novelty rejection.
Non-obviousness is the most difficult hurdle in obtaining a patent. A patent will not be issued if a person skilled in the field would look at all the prior art related to the invention (and all the other knowledge in the world) and come up with the invention as an obvious combination of things that already exist. While this sounds like a challenging test, there are many ways around an obviousness rejection, such as demonstrating that the invention has unexpected characteristics.
When looking at novelty and non-obviousness, the important thing is demonstrating how your invention is different than what is already out in the world. You should focus on identifying the differences in your invention from the prior art that will result in you obtaining a patent.