What is base 64 encoding used for?

It's basically a way of encoding arbitrary binary data in ASCII text. It takes 4 characters per 3 bytes of data, plus potentially a bit of padding at the end. Essentially each 6 bits of the input is encoded in a 64-character alphabet. The "standard" alphabet uses A-Z, a-z, 0-9 and + and /, with = as a padding character. There are URL-safe variants.

Why do we use Base64?

Base64 is an ASCII only representation of a binary file, using only upper and lower case alpahabet characters and the figures 0 to 9, + and /. The base64 scheme converts 3 bytes of binary data into 4 bytes of printable data, and is mainly used to include (embed) images in Text-only emails.