Being denied entry isn't illegal, and isn't necessarily going to adversely affect future entry attempts. Overstaying your visa, or illegally entering a country on the other hand is a crime. If you have committed crimes in a country, you will have a harder time getting in next time.