This answer is extended from my comment to Ross Milikan's answer to your question Numerical FEN writing.
There is a website devoted to counting the number of legal positions up to equivalence with given number of pieces. Currently they have results for positions with 2 to 8 pieces.
2: 462
3: 368,079
4: 125,246,598
5: 25,912,594,054
6: 3,787,154,440,416
7: 423,836,835,667,331
8: 38,176,306,877,748,245
With their definition, a position is legal if:
- It has exactly one white and one black king
- There are no pawns on the 1st and 8th lines
- Side to move is not giving a check
Note that with these definitions, some positions could be legal even if they cannot be achieved in a real game. Edit: As @Pimgd pointed out in the comments, an example is a position with white pawns on a2, b2 and a3.
Two positions are considered equivalent if they are essentially the same, in this case, one position can be obtained from another by combining the following operations:
- Any position: Swapping the colours of the pieces, the side to move, and mirroring the position around the horizontal line such that the square a1 becomes a8 etc.
- Positions with no castling rights: mirroring the position around the vertical line such that the square a1 becomes h1 etc.
- Pawnless positions with no castling rights: mirroring the position around the horizontal line such that a1 becomes a8 etc.
- Pawnless positions with no castling rights: Mirroring the board diagonally
Depending on the existence of pawns and castling rights, each "unique" position thus corresponds to 2 to 16 different positions.