1. Each desk has four legs.

2. Each of the desks has four legs.
3. All desks have four legs.
4. Every desk has four legs.
5. There are four legs on each desk.
-----------------------------
Are they all grammatical? Which one is wrong?

All are correct except #3.

Reason: If you have ten desks, you wouldn't say they have four legs. You'd say they have forty legs all together.

All of the sentences you provided are grammatically correct.