The ratings system used by the ICC to rate countries is a modified (simplified) form of the Elo rating systems. The basic idea behind these type of systems is that
A win always increases your rating
A lose always decreases your rating
The amount the rating changes by depends on the rating of the two teams before the match
If a low rated team beats a high rated team, the rating will change by more than if two very closely rated teams play. You can never get a negative rating, since what happens in the calculation is that there are ratings points and the number of games in the ratings period. The actual rating is the points divided by number of games. You can only earn ratings points, so if you lose every game you just have zero points. However, if you get earn no points from a game your rating will decrease since the ratings points stays the same but the number of games increases.
The full details of the ICC rating system is given in on wikipedia. An important aspect is that more recent matches are given a greater weighting than more distant games.
Originally, the idea was that all teams must play every other team within a time window (I think it was 5 years) and only the most recent series against each opponent would count and be weighted equally. This was abandoned in favour of the above mentioned weighting of recent games because the cricket boards didn't want to be locked in rigidly to completing all the series that this would require. Basically teams like India, Australia, England and South Africa want to be playing each other much more often because that generates more revenue than playing against smaller countries like New Zealand or the West Indies. Particularly, everyone wants to play India as much as possible because that is where most of the money in world cricket flows from.
The ICC maintains separate ratings tables for Test Cricket, One Day cricket and T20 cricket. There are not the same number of teams in each table, since there are fewer Test playing nations than ODI and T20.