Firmware is specific to hardware and it's capabilities. This applies to routers, phones (not only smartphones), big routers, switches, bridges, you name it. There's certain part of firmware that does low-level tasks like reading from Flash/disk storage, the next part tells how to talk to radio or how to talk to an onboard LAN chip. In case of (A)DSL routers there's also a part that's responsible for dialing and DHCP, DNS et cetera. Other parts are responsible for serving you your WEB interface, whose options differ between routers, as you probably guessed, by hardware capabilities (that's the why different models within the same router manufacturer use different firmware part).
All these parts pertaining to hardware or presentation (we'll call them drivers
, for simplicity) are told by some central program what to do. This program manages interactions between various drivers / modules, and doesn't let them do nonsensical things. We'll call this central manager a kernel
, again, for simplicity.
With the above in mind, you migt say Hey, it looks like a linux / windows / whatever box, looking at this structure!. Well, that's right! it doesn't have keyboard nor mouse, but it is, in reality, a small, task-specialized computer. Many of them home routers DO use linux (well, not windows) or are capable of running one (e.g. Tomato).
As for why there are people writing new firmware for them - imagine you have a router that doesn't implement specific functionality you care about (in my case it was static-assigned DHCP). But out there is a Tomato router firmware, which DOES have this feature, and it DOES support your router's hardware. Why not use it? (aside from forfeiting manufacturer's warranty). I would and I do. So the answer is - people write different firmware for our routers, because there's a demand for it, caused by original manufacturer's incapability / unwillingness / slowness of implementing features.