The 256-colour ceiling explains everything
A GIF stores a palette of at most 256 colours and then records, for each pixel, which palette entry to use. The compression that follows is lossless — but the colour reduction that happens first is not, and it is where all the quality goes. A photograph has far more than 256 distinct colours, so converting one to GIF means discarding the overwhelming majority of them.
Encoders paper over this with dithering: scattering pixels of two palette colours in a pattern so that, from a distance, the eye blends them into a third. It works surprisingly well, but it replaces smooth gradients with visible speckle, and because the speckle is high-frequency noise it also defeats the LZW compression, which is why dithered GIFs are often larger than undithered ones.
Why transparency looks ragged
GIF transparency is a single flag: one palette entry is designated transparent, and every pixel either uses it or does not. There is no partial opacity. An anti-aliased curve or piece of text, which relies on semi-transparent edge pixels to look smooth, cannot be represented — so the encoder has to composite those edges against some background colour and make everything else fully opaque.
That is the source of the classic ugly halo: a GIF logo exported against white and then placed on a dark page shows a fringe of white pixels around every curve. PNG, WebP, and AVIF all solve this with a proper alpha channel.
Animated GIFs are enormous, and what replaced them
GIF has no concept of motion between frames in the way a video codec does — it cannot say "this region moved three pixels left". It only supports skipping unchanged rectangles. A few seconds of real footage therefore becomes a file many megabytes in size, at 256 colours, where an equivalent MP4 or WebM would be a tenth the size and look considerably better.
This is why most "GIFs" on the modern web are not GIFs at all. Social platforms and messaging apps accept a GIF upload, transcode it to video behind the scenes, and serve you an MP4 in a looping player. The word survived; the format mostly did not.
Converting GIF files
For a still GIF, converting to PNG is lossless and usually smaller — the palette comes across intact and PNG's compression is simply better. Converting to WebP or AVIF shrinks it further and lets you keep proper transparency if you re-export the edges.
For an animated GIF, animated WebP typically lands around a fifth of the size with full colour, and is supported by every current browser. Converting to MP4 or WebM saves more still, at the cost of no longer being an image — it will not work in an <img> tag or in an email.