The difference between Raw and JPEG is mainly about
bit depth.
But a Raw image is an unfinished image the photographer has to, well finish, using Raw conversion software.
JPEG is intended to be a finished ready-to-print file type that has already been 'finished' in the camera. Many photographers prefer to do the 'finishing' them selves because the camera is just a dumb (inanimate) machine that is running a program written by software engineers long before you ever took the photo.
Put another way, how much artistic control are you willing to grant the machine?
DSLR cameras make 12-bit or 14-bit Raw image files. JPEG is limited to an 8-bit color depth.
A 8-bit digital number - 11111111 - can represent only 256 distinct gradations of tone (color).
A 12-bit digital number - 111111111111 - can represent only 4096 distinct gradations of tone (color).
A 14-bit digital number - 11111111111111 - can represent only 16,384 distinct gradations of tone (color).
Since digital images are based on the RGB color model, a digital image has 3 color channels - Red, Green, and Blue.
So a JPEG is also known as a 24-bit image because it has 3, 8-bit color channels - 3 color channels x 8-bits per color channel = 24-bit digital image.
By the same token a 12-bit digital image is also known as a 36-bit image - 3 color channels times 12-bits per color channel = 32-bit digital image.
Raw files have to be converted into an actual image outside of the camera in one of the many Raw Converters.
JPEGs are most often made right in the camera, thought eh camera starts with a Raw file for every image it delivers.
But to make a JPEG in the camera, the camera has to discard a lot of the color information the camera image sensor actually recorded.
FWIW, the image sensor in a digital camera actually cannot record color, the image sensor can only record luminosity. Color has to be interpolated based on a filter (Bayer Array) in front of the image sensor.
These and and other fundamental concepts are found in this group of related tutorials -
Photo Editing Tutorials