You will find a pinned topic on this above, but here are the basic outlines:
Fish produce waste containing ammonia. This is toxic to them.
Friendly bacteria change the ammonia into nitrites. This is also toxic.
Friendly bacteria changes nitrites into nitrates. less harmful and you dilute them via water changes.
A new tank does not contain enough of these friendly bacteria. If ammonia is introduced (e.g. when you put fish in), they will develop over a period of maybe 4-6 weeks. This developing of bacteria is known as cycling the tank or the cycle. Once there are enough bacteria to cope with the current fish tank the tank is said to be cycled. If you add too many new fish the tank may go through another minicycle. The bacteria mainly live in the filter media and the gravel.
There are 2 ways of cycling the tank:
You can cycle with fish, by adding a few hardy starter fish (such as danios or platys). This is quite stressful to the fish as they start off their time in your tank swimming on toxins; you need to monitor the levels of ammonia and nitrites quite carefully and be prepared to dilute them with frequent water changes.
Or, you can cycle with ammonia out of a bottle, by adding a few drops of pure household ammonia to the tank every day until the readings of ammonia and nitrites show you that the tank has completed its cycle. You then do a big water change. Once this is done you can add pretty well all your fish. This latter method has quite a few advantages. It is more humane and also gives you a greater variety of first fish to choose from. The disadvantage is you have to wait a few weeks (mine took 10-14 days, some take more), before you can add any fish at all. You can always spend this time putting in plants though (they don't mind) and researching your fish.
Either way you need to invest in a test kit for ammonia, nitrites and nitrates (and ph is a good idea). The liquid ones are the most accurate.