The available() function returns the number of bytes (characters) available for reading in the serial port buffer. If it is zero then there is nothing to read. So the loop() runs until there is something to read. When you read something you take the number value of the character in the ASCII code. So if you just send back what you read the serial monitor will display a number. To turn that number back to a character you use a cast, the (char) thing before the variable in Serial.print(), which does just that. More on casts on wikipedia here.