What happens when you convert RGB to hex
Nothing is lost and nothing is gained: they are two notations for the same three
numbers. RGB writes each channel in decimal from 0 to 255, and hex writes the same
channel in base 16 as two characters. rgb(75, 153, 74) and #4B994A are byte for
byte the same colour.
The conversion is per channel. 75 in base 16 is 4B, 153 is 99, 74 is 4A, and concatenating them gives the hex code. That is the entire operation, which is why this page is instant and needs no file.
Why hex exists at all
Two characters per channel means a colour is always exactly six characters, which
made it compact and unambiguous in early HTML and CSS. Decimal channels vary in
length from one to three digits, so they need separators and a wrapper, and
rgb(75,153,74) is thirteen characters against six.
Hex also aligns with how the value is stored. A colour in memory is three bytes, and one byte is exactly two hex digits, so the hex string is a direct transcription of the bytes with no arithmetic in between.
When you want RGB instead
Three situations.
Transparency, when the alpha is variable. rgba() and the modern
rgb(r g b / a) syntax let you set opacity in the same declaration, and while
8-digit hex can do it too, most people find / 0.5 easier to read than 80.
Computed values, where a channel comes from a variable or an animation. Building a
hex string from numbers means formatting and padding; rgb() takes the numbers
directly.
Canvas and image work, where the pixel data is already three integers per pixel. Converting them to hex to hand to an API that will parse it straight back is pointless work.
The other notations on this page
HSL describes the same colour as a hue angle plus saturation and lightness, which is far easier to adjust by hand: shifting hue by 30 degrees or dropping lightness by 10 percent are single-number edits, where the equivalent in hex is three unrelated changes.
HSV is what the colour pickers in Photoshop and Figma show, so it is the notation to match when you are copying a value out of a design tool.
CMYK is included for print work, with the caveat above: without a colour profile it is an approximation.