Since space is not that clean, always there is a chance to hit by an asteroid / meteor. So how can satellites remain safe orbiting Earth?
There are actually quite a few methods satellites use to avoid collisions.
Under international space law (outer space treaty) no one and no country "owns" an orbit which mean technically it is a free for all. However, any organization with a satellite is generally pretty committed to not having it get hit, so conventions are followed.
First tracking, the US maintains CSpOC (formerly JSpOC) which tracks every item in orbit with ground based radar over 10cm in diameter. This data is fed into an orbit determination routine which creates a TLE for every item in orbit. This information is used as an initial condition in a propagation code which generates a predicted future orbit for every object in orbit. These orbits are then analysed for future collisions. Collision predictions (and close encounter predictions) are then emailed to satellite operators before the predicted collision to take appropriate counter measures.
The CubeSat lab I work in gets roughly about 1 notification (close encounter only) per month. This is a regular cyclic notification is partially because CubeSats are released in batches and most have no propulsion which means they all will have very similar orbits.
Here is some data to help inform this discussion. This plot shows the number of trackable objects in orbit as a function of time since the beginning of humanity's entry into space. There are a couple of interesting features to note. In 1996 there is a vertical uptick in objects, and again in 2000, and 2002. There is a huge uptick in 2007 and more smaller upticks in 2008 and 2009.
The 1996 uptick was a US anti-sattelite test. The US congress banned anti-satellite testing after this test because of the orbital debris implications it had.
The 2007 uptick is because of the Chinese anti-satellite test. This is why space people were mad about it too. The problem was not the test itself, it was the orbit they tested it in (it was too high).
The 2009 uptick is because the first (and as of March 2019 only) accidental collision in orbit between two satellites. The Iridium-Cosmos collision was tragic as both the US and Russia had systems that could of warned the operators of the collision. JSPoC had been sending collision warnings to Iriduim up until at least 2007, however the notification system was discontinued for commercial operators because it was deemed to send to many warnings. After the collision JSpOC notifications were continued and is now an important feature of orbital operations.
Second, satellites in GEO use a couple of interesting features to mitigate collision. Although no orbits are "owned"; RF Spectrum is. This allowed an international body to sell GEO slots based on what frequencies can be used there. This had the effect of creating an orderly process of going into GEO using your slot for the allotted time and then boosting after the mission is over.
Third, NASA has the 25 year de-orbit rule (this is not for all orbits). This requires satellite operators to show with simulations that their satellites will come down in 25 years or less. This simulation is required as part of the launch licencing procedure. Again, technically no one "owns" orbits, but NASA can sort of limit what can go where with this because launch licences are required.
There are some other methods used to keep satellites safe like Whipple shielding, but I won't further bore you with the details.
Lastly, space debris is a problem because everyone tends to want to use the same orbits. CubeSats are practically built for sun-synchronous orbits, comm-sats are built for GEO and so on. This creates a handful of orbits that are densely packed and a bunch other ones that still have basically nothing in them. People tend to mis-understand the risk of space debris. Even if a kessler-like syndrome were to occur, it would mostly affect the most valuable orbits (Sun-synch, GEO, etc). There would still be a lot of debris-free orbits, but they wouldn't be as useful. If you just do a straight up probability of collision analysis assuming randomly distributed orbits you get an absurdly low chance of collision. Unfortunately, satellites are not placed randomly which makes select areas at risk for debris problems.
They aren't. The risk is always there, but low enough that satellites usually reach end-of-life (be it due to failing devices, running out of fuel needed for station-keeping or the technology becoming obsolete) before that can happen.
There are also mitigating techniques. All major debris and orbits filled with debris are well mapped out and no satellites are put in these. Satellites put out of service are placed in "graveyard orbits" or just deorbited not to endanger other satellites in orbits similar to their operational ones. For interplanetary missions, boosters are dropped on Earth escape trajectory - so they enter Sun orbit where the debris density becomes negligibly small.
But the risk is real. Sometimes satellites are hit by debris and break up into more. The "business side" is covered by insurance. The orbital mechanics side is covered by mapping the new debris field trajectory and not putting any new satellites in its path, maybe also moving existing ones to safe orbits where viable. Also, most propulsion-less satellites, like cubesats are put in orbits low enough that they decay over the course of a couple years and the satellites deorbit by themselves naturally. But besides that - it's all just probability calculations, insurance and dumb luck.
p.s. look up the phrase "Kessler syndrome." It's rather chilling.